;Fermat's little theorem
;If N is a prime number and A is any positive number less than N, then (A^N % N) == (A % N). (A^N stands for A raised to the Nth power.)
;This theorem can be used to test the primality of a number. If the above relation is not satisfied for a N, then N is certainly not a prime. If the above relation is satisfied for a N, then the chance is good that N is a prime. The equation is necessary for N to be a prime, but it is not sufficient.
;The programs followed are a implementation for testing the primality of a N.