How about this pseudocode:
Code:
Loop X from START to END (We are testing X to see if it is prime):
(Right now, X is prime as far as we know.)
bool isPrime = true;
Loop i from 2 to X (Don't include 1 or 0, because dividing by 0 gives error, and dividing by 1 always has no remainder)
If X is evenly divisible by i
X is not prime.
Change isPrime to false, break from loop (no need to continue).
Else
Take no action (Can't be sure it will remain prime.)
End Loop
(Now, isPrime correctly indicates X's state).
If X is prime
Take appropriate action
Else
Take appropriate action
End Loop
Comment