Is 1 considered prime?

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

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Yeap u r right that 1 is not a prime number.
along with wiki where ever we see we find that 1 is neither prime not composite it lies in special category.
another url for ref : http://mathworld.wolfram.com/PrimeNumber.html.

so 1 is not prime.

Answet to your 2nd question.
1st & 2nd arguments are closed range, in mathematic terms [range1, range2]
means primes number should be in between these including them.

Yes, consider that 1 is not a prime. Good point: We would not pass "1" as the 1st parameter range1.

Thanks
-Rama

Rama,

Quoting Rama Kishan Malladi (Intel)
Good point: We would not pass "1" as the 1st parameter range1.

Does that mean the first and second parameters [range1, range2] will both be primes? It simplifies the logic slightly if we can assume that they are. Otherwise we have to search for the next prime >= range1 and the last prime <= range2.

- Rick

I do not think, it means that both parameters will be primes. They may be anything but both are inluded.

Please don't assume that range1 and range2 will be prime. Assume generic case.

Thanks
-Rama

There are any tests except from task?

Quoting dotcsw
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

Oops. That was a bad example. 9 is not prime.

- Rick

Leave a Comment

Please sign in to add a comment. Not a member? Join today