Here\'s a piece of code to compute all primes from 2 to 1000 using the statement, that a number n is a prime number iff:
In the first version I think that I
Java doubles (i.e., the outputs of pow) do not represent large numbers precisely enough to yield a correct remainder. You should switch to modular exponentiation.
double
pow