Fermat's Little Theorem
- For any prime p and integer a not divisible by p: a^(p-1) ≡ 1 (mod p)
- Reveals primes create regular structure in modular exponentiation via multiplicative cycling
- Stated by Fermat (1640) without proof; first proven by Euler (1736)
- Generalizes to Euler's Theorem and emerges from Lagrange's Theorem on multiplicative groups
- Foundation for modern cryptography, primality testing, and computational number theory
- Shows why primes are special: only they make all non-zero elements cycle predictably
Fermat's Little Theorem
Overview
Fermat's Little Theorem stands as one of the most elegant and useful results in elementary number theory, establishing a fundamental relationship between prime numbers and modular arithmetic. Despite its deceptively simple statement, this theorem underpins much of modern cryptography, primality testing, and computational number theory. For a first encounter with deep number-theoretic ideas, Fermat's Little Theorem offers the perfect balance: accessible to prove with basic tools, yet profound in its applications.
The theorem tells us something remarkable: when you raise any integer to the power of a prime , then reduce modulo , the result depends only on the original integer modulo , and in particular, if the integer is not divisible by , raising it to the power always yields 1. This is not obvious—why should exponentiation interact so cleanly with division by primes? The answer lies in the structure of modular arithmetic and the properties that make primes special.
Historically, Pierre de Fermat stated this result in a letter to Frénicle de Bessy in 1640, though he provided no proof. The first published proof came from Leonhard Euler in 1736, who later generalized it to the more comprehensive Euler's Theorem. The theorem has since become a cornerstone of algebraic number theory and group theory, where it emerges as a special case of Lagrange's Theorem applied to the multiplicative group of integers modulo a prime.
Fermat's Little Theorem reveals that prime numbers impose a regular, predictable structure on exponentiation: every non-zero element, when raised to the power , becomes 1 modulo . This "multiplicative cycling" is unique to primes and is the foundation for their role in cryptography.
Fermat's Little Theorem: Let be a prime number. Then for any integer not divisible by , we haveCore Theory
Main Result
Theorem [1] (Fermat's Little Theorem): Let be a prime number and let be an integer with . ThenWe present two proofs of Theorem [1], each illuminating different aspects of the result.
Proof 1 (Combinatorial Argument via Multiplication):Consider the set of non-zero residues modulo .
Since , multiplication by is a bijection on modulo . That is, the set
To see this: if for , then . Since is prime and , by Euclid's Lemma we have . But , so . Thus all elements of are distinct modulo , and since there are of them, they must be exactly in some order.
Therefore:
This gives us:
Now is not divisible by (since each factor is less than ), so . By the cancellation law in modular arithmetic, we can divide both sides by :
Consider the multiplicative group under multiplication modulo . Since is prime, this is indeed a group of order .
By Lagrange's Theorem from group theory, the order of any element divides the order of the group. If , then the order of divides , meaning in the group, which translates to .
Proof of Theorem [2] from Theorem [1]:If , then by Theorem [1], , so multiplying both sides by gives .
If , then , so . □
Common Error: Fermat's Little Theorem requires to be prime. Students often mistakenly apply it when is composite. For example, with and , we have , not 1. The theorem fails completely for composite moduli (though Euler's Theorem provides the correct generalization using the Euler totient function). Pierre de Fermat (1640) — First stated this theorem in correspondence, claiming to have a proof but never publishing it, launching centuries of investigation into modular arithmetic and prime numbers.Examples and Applications
1
Computing large powers efficientlyCalculate .
Solution: Since 11 is prime and , Fermat's Little Theorem tells us thatWe write , so:
Without Fermat's Little Theorem, computing directly would be computationally intensive. This theorem reduces the problem dramatically.
2
Finding modular inversesFind the multiplicative inverse of 7 modulo 13.
Solution: We seek such that .By Fermat's Little Theorem, . Rewriting:
So is our inverse. We compute efficiently:
Check: . ✓
Thus the inverse of 7 modulo 13 is 2.
Why the prime hypothesis is essentialConsider and (composite). If Fermat's Little Theorem applied to composite moduli, we'd expect .
However, , so , not 1.
The failure occurs because the multiplicative group has order , not . For composite , we must use Euler's Theorem: when . Here , and indeed fails too (it gives ), illustrating that even Euler's theorem requires coprimality!
Actually, , so neither theorem applies. For a valid example: . ✓
Mental Model: The Cyclic OdometerImagine an odometer with positions (where is prime) that advances by multiplying by each step, wrapping around modulo . Since is prime, the only way to return to position 1 is if you've hit every non-zero position exactly once (or some divisor's worth of times).
Fermat's Little Theorem guarantees that after exactly steps, you're back at 1. The primality of ensures that multiplication by any creates a permutation of the non-zero residues—there are no "short circuits" or smaller cycles (unless has smaller order dividing ).
Geometrically, think of the non-zero residues as nodes in a cycle graph. Multiplication by is an arrow from each node to another. Primality ensures this graph is strongly connected: starting from 1, you can reach every other node and return, creating a beautiful cyclic symmetry.
Historical Development
Pierre de Fermat first stated this theorem in a letter dated October 18, 1640, to his correspondent Frénicle de Bessy. As was typical for Fermat, he claimed to have a proof but did not provide it, writing instead that he would send the demonstration if Frénicle had trouble finding it himself. No proof from Fermat survives.
The first published proof appeared in 1736 by Leonhard Euler, who recognized the theorem's importance and placed it on rigorous footing. Euler later generalized the result around 1760 to what is now called Euler's Theorem, which applies to composite moduli using the Euler totient function . This generalization states that when , recovering Fermat's Little Theorem as the special case where is prime (since ).
The theorem gained new practical importance in the 20th century with the development of public-key cryptography. The RSA algorithm, invented by Rivest, Shamir, and Adleman in 1977, relies crucially on Fermat's Little Theorem and its generalization for both encryption and efficient computation of modular inverses.