P1: A2 - Consecutive Primes (Archived)


Can the algorithm we use for generating the prime numbers initially
know that 2 is a prime number, or do we need to discover this fact each time
we run the program?

Algorithm use

Hi there,

Just a thought regarding the "original creation" phrase in the rules:
how would it be viewed if I said, for example, "I implemented algorithm
ABC by John Smith to solve this problem"? Assuming that the algorithm
is in the public domain, of course, and available to be used by anyone (for non-commercial use at least),
is that all OK?

Output precision

The problem definition states that "the input values will be represented with 32-bit unsigned integers". Is it safe to assume that the output values (including the sums of primes) will also representable with 32-bit unsigned integers?

When you start adding together large 32-bit values, pretty soon you're talking 33 or 34 bits. It will impact the performance of the inner loop if those calculations must be done with 64-bit integers.

- Rick

Sidecases, what to report?

From the example case

sum(17:19) = 36 = 6**2
sum(5:13) = 36 = 6**2

I'm able to tell that if several sequences produce the same sum they all have to be reported, but how do we handle duplicates on the power side of things?

for instance:

sum(20063:32987) and sum(2097031:2097287) both produce 33554432 (frist draft of my app, results could be wrong) no problem just report both lines, yet 33554432 gives an interesting sidecase being both 2^25 and 32^5.

Is 1 considered prime?

Wikipedia says that 1 is no longer considered prime by mathematicians. How should it be handled for the purposes of this challenge?

Looking at the example output from "primesums.exe 1 29 6 sumsout.txt" one thing I do not see is:
sum(1:9) = 27 = 3**3

So my guess is that 1 is not prime. This leads to my next question...

Can we assume that the first and second command line arguments are prime?

- Rick

Consecutive Primes, Apprentice Problem 2, is LIVE for the Threading Challenge 2011.

Consecutive Primes, Apprentice Problem 2 for the Threading Challenge 2011 is now LIVE! We hope you will enjoy working this coding problem. Don't forget that the Intel Manycore Testing Lab will be unavailable from approximately 5:00pm, Pacific Daylight Time (PDT), May 27 through 9:00am, PDT, May 31, 2011. Please plan aacordingly. Good Coding!

P1: A2 - Consecutive Primes (Archived) abonnieren