Proof of Fermat's (Little) 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
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
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.