Lecture 22

Proof of Fermat's (Little) Theorem


The form of the theorem that we will use is

ap=a (mod p)

for every prime number p and every integer a < p. The following proof is based on induction, and the binomial theorem.

Proof of Fermat's Little Theorem:
First, note that the theorem is obvious if a=1, since 1p=1, and 1 = 1 (mod p)

Next, assume the theorem is true for a>1.

Note: the binomial expansion of (a+1)p is given by

(a+1)p = ap + pap-1 +p(p-1)/2! ap-2+...+pa+1

Consequently, after subtracting the first and last terms of the right hand side from the left, we have (a+1)p-ap-1 = 0 (mod p), since each of the remaining factors is divisible by p. (Note: the leading term p in p(p-1)(p-2)...(p-i+1)/i! cannot be cancelled by the denominator if p is prime).

By the induction hypothesis, ap-a=0 (mod p), therefore the sum

(a+1)p-(a+1) =
(a+1)p-ap-1+ap-a = 0 (mod p)

The conclusion that we reach is that if ap-a != 0 (mod p) then p is composite (not prime). This provides a quick test.

On the other hand, if ap = a(mod p) for all a < p, that does not mean that p is prime. p=561=3*11*17 is a counter example. It is the smallest such number.


Other proofs of Fermat's little theorem.