HINTS ABOUT
PRIME NUMBERS


1. Use the % or "remainder" operation:
A % B = remainder when A is divided by B,
so A % B = 0 whenever A is exactly divisible by B.

2. A prime number has no exact divisor except itself and 1. So, test whether it is exactly divisible by 2.
(If it's not divisible by 2, then you don't need to test any more even-number divisors.) SO:
Test if it is exactly divisible by 2;
Then test if it is divisible by any ODD DIVISOR
(3, 5, 7, etc.)

3. If a number N is divisible by 2, then its largest divisor is N/2.
If a number N is NOT divisible by 2, then its largest divisor is less than N/2. SO:
You don't need to test any divisor greater than N/2; you can stop testing when you reach that value.

4. For a prime number like 17, give an answer like:
"17 is a prime number."

5. For a number that is not prime, like 15, give an answer like:   "15 is divisible by 3, so it is not prime."

6. Try to add ERROR CHECKING:
For non-numeric input, say:
  "You must type in an integer."
For numbers with fractions, say:
  "You must type in an integer."
For negative numbers or zero, say:
  "Your number must be positive."
CLICK HERE for more details.