Overview
Fermat's little theorem is a universal statement about powers modulo a prime. It lets one reduce large exponents and detect some composite numbers without factoring them. Its strength comes from working in a finite multiplicative group. The hypotheses are indispensable, and the converse is false: passing a particular power test does not establish primality.
Prerequisites
Understand congruence, prime numbers and coprimality. A nonzero residue modulo a prime is invertible. For the group interpretation, know the order of an element and Lagrange's theorem; the elementary proof only requires cancellation of invertible residues.
Definition and conventions
If is prime and is an integer with , then
An equivalent formulation, with no restriction on , is . For multiples of , this second statement holds because both sides are zero modulo . For other integers, multiply the first statement by . This is the little theorem, not Fermat's last theorem about sums of positive integer powers.
Intuition
Multiplication by a nonzero residue rearranges the nonzero residues modulo . It cannot lose a residue, create a zero, or identify two different residues because multiplication is invertible. The theorem captures a numerical consequence of this finite symmetry. It does not say that is the smallest exponent giving one.
Examples and non-examples
To find modulo , use . Since , the answer is . This reduces a large calculation to one small power.
For the composite modulus , , not one. Yet some composite moduli pass particular tests: and , so . This explicit counterexample prevents reversing the theorem even for an integer coprime to the modulus.
Important properties
An elementary proof compares the product of all nonzero residues with its image after multiplication by . The image is a permutation, so the products agree. Factoring out one from each of the terms gives times the original product. The product is invertible, so cancellation gives the theorem.
Equivalently, the group has elements. The order of divides by Lagrange's theorem. Thus a failed congruence proves compositeness, but a successful congruence may reflect only one element's order, not the primality of the modulus.
Connections and further reading
Euler's theorem replaces with the number of units for a composite modulus and explicitly requires coprimality. More sophisticated primality tests use stronger conditions. Conrad's note treats the elementary proof and testing limitations.