Fermat’s little theorem gives a condition that a prime must satisfy:

Theorem. If P is a prime, then for any integer A, (A^{P} – A) must be divisible by P.

Let’s check:

2^{9} – 2 = 510, is not divisible by 9, so it cannot be prime.

3^{5} – 3 = 240, is divisible by 5, because 5 is prime.

**Presentation Suggestions:**

This may be a good time to explain the difference between a necessary and sufficient condition.

**The Math Behind the Fact:**

This theorem can be used as a way to test if a number is *not* prime, although it cannot tell you if a number is prime.

Fermat’s theorem is a special case of a result known as Euler’s theorem: that for any positive integer N, and any integer A relatively prime to N: (A^{phi(N)} – A) must be divisible by N, where phi(N) is *Euler’s totient function* that returns the number of positive integers less than or equal to N that are relatively prime to N. So when N is prime, phi(N)=N.

Fermat’s “little” theorem should not be confused with Fermat’s Last Theorem.

**How to Cite this Page:**

Su, Francis E., et al. “Fermat’s Little Theorem.” *Math Fun Facts*. <https://www.math.hmc.edu/funfacts>.

**Fun Fact suggested by: **

Lesley Ward