Fermat's little theorem and the hidden symmetry of remainders
From the group structure of (Z/pZ)* we derive Fermat's little theorem, explain why the set {a, 2a, ..., (p-1)a} is a permutation of {1, 2, ..., p-1}, show that a^{p-2} is the modular inverse, and generalize to Euler's theorem.
Fermat's little theorem is one of the most frequently invoked results in number theory. The statement – if is prime and , then – is concise, but behind it lies a beautiful symmetry in the world of remainders.
1 The statement
2 The permutation argument: the heart of the proof
3 The group
Fermat's little theorem admits a clean algebraic interpretation.
Closure: and imply .
Associativity: inherited from integer multiplication.
Identity: .
Inverses: computed via the extended Euclidean algorithm (previous article).
4 Whyis the modular inverse
5 Modular inverses in competitive programming
Fermat's little theorem: compute by repeated squaring in .
Extended Euclidean algorithm: also , with a smaller constant.
6 Generalization: Euler's theorem
7 Takeaway
Fermat's little theorem: if is prime and , then .
The proof rests on the observation that multiplication by permutes the set .
In the language of algebra, this is Lagrange's theorem applied to .
The identity is a direct consequence, giving the modular inverse.
The generalization is Euler's theorem, which provides the theoretical foundation for RSA encryption.
In the next article, we explore the "merging" of simultaneous congruences – the Chinese Remainder Theorem.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.