Fermat’s Little Theorem: Let p be a prime and let a∈Z. Then
ap≡a(modp).Equivalently, if p∤a (i.e., a≡0(modp)), then
ap−1≡1(modp).Here x≡y(modp) means that p divides x−y.
This is a standard application of Lagrange's theorem
to the group of units
(Z/pZ)×, a finite group
of order p−1. It is also the prime-modulus special case of Euler's theorem
(since φ(p)=p−1).
Proof sketch (group-theoretic): If p∤a, the residue class of a is an element of (Z/pZ)×. By Lagrange’s theorem, raising any element to the power p−1 gives the identity in this group, which translates exactly to the congruence ap−1≡1(modp).
Examples:
- p=7, a=3: 36=729=7⋅104+1, so 36≡1(mod7).
- p=5, a=10: both 105 and 10 are divisible by 5, so 105≡10(mod5) (this is the “ap≡a” form).
- If p∤a, then ap−2 is a multiplicative inverse of a modulo p (since a⋅ap−2=ap−1≡1). For instance, with p=7, a=3: 35=243=7⋅34+5, so 3−1≡5(mod7) because 3⋅5=15≡1(mod7).