In mathematics, a prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself.
The Fundamental Theorem of Arithmetic for more information."; } //special message for 2 else if ($x==2){ echo "2 is a prime number, and the only even prime."; } //divide x by all numbers between 2 and x-1, stop when a whole # is found else { for ($i = 2; $i < $x; $i++) { if ($x % $i == 0){ echo $x." is not a prime number.\n"; exit(); } } //if loop completes with no whole # found, the number must be prime echo $x." is a prime number!"; } } ?>