Euler's Theorem
How does a computer decide, in a fraction of a second, that ? It never computes the astronomically large number . The answer rests on a single congruence discovered by Leonhard Euler in the 1760s. It is one of the most quietly powerful facts in elementary number theory. It says that raising any integer coprime to to the power — Euler's totient — always returns modulo . This single sentence subsumes Fermat's Little Theorem as the special case of a prime modulus. It also converts the seemingly wild problem of computing huge powers modulo into a bounded, mechanical calculation. The idea matters because modular exponentiation is the engine of modern cryptography. RSA encryption, Diffie–Hellman key exchange, and primality testing all lean on one fact. Exponents can be reduced modulo (or a close relative of it) without changing the answer modulo . Beyond applications, Euler's theorem is a paradigm example of something deeper. It shows how group structure — here, the group of units modulo — controls arithmetic. The proof is a masterpiece of economy. It permutes a set of residues by multiplication and reads off the answer. This technique recurs throughout algebra and number theory. The big picture is this: congruences modulo that are coprime to form a finite abelian group under multiplication. This is the group of units , of order . Euler's theorem is nothing more than a special case of Lagrange's theorem from group theory. The order of every element divides the order of the group. Seen this way, it is not an isolated curiosity. Instead, it is the arithmetic shadow of a structural fact about finite groups. This article states Euler's totient function and reduced residue systems as known background. It proves Euler's theorem completely and rigorously via the classical permutation argument. It works through two nontrivial numerical examples. It shows exactly which hypothesis cannot be dropped. Finally, it points toward the finer theory of the order of an element. This concept refines Euler's theorem by asking for the smallest exponent that works.
- Euler's theorem: if then .
- It generalizes Fermat's Little Theorem, which is the case prime, since .
- The proof permutes a reduced residue system by multiplication by and compares products.
- It reduces modular exponentiation with huge exponents to a computation modulo .
- Coprimality is essential; without it the congruence can fail entirely.
- Key idea: the units modulo form a group of order , and Euler's theorem is Lagrange's theorem in disguise.
Where this lives today
Euler's theorem is the arithmetic backbone of the RSA cryptosystem: encryption and decryption exponents are chosen so their product is congruent to modulo (for an RSA modulus ), guaranteeing via Euler's theorem that decryption recovers the original message modulo , for any message coprime to . The theorem is also the reason why modular exponentiation algorithms used throughout cryptography and computer algebra systems can safely reduce huge exponents modulo before repeated squaring, turning otherwise infeasible computations into millisecond operations. In abstract algebra, Euler's theorem is the concrete number-theoretic instance of Lagrange's theorem applied to the group of units : the order of any element of a finite group divides the order of the group, and here "order of the group" is exactly . This connection is the natural bridge from elementary number theory into group theory proper. In computational number theory, Euler's theorem underlies Euler pseudoprime and Fermat primality tests, which check the congruence (or refined variants) for random bases as a fast probabilistic filter before applying slower deterministic primality tests. In combinatorics on words and cyclic structures, the totient function and Euler's theorem appear in counting formulas such as the number of aperiodic binary necklaces, via Möbius inversion built on the same group-of-units framework. In physics and engineering, modular arithmetic governed by these same principles appears in signal processing (cyclic convolution and the discrete Fourier transform over finite fields) and in error-correcting codes, where arithmetic modulo carefully chosen exploits the predictable periodicity Euler's theorem guarantees.
Ask the tutor: How does the order of an element refine Euler's theorem, and how do we find it in practice?
For a positive integer , Euler's totient function counts the integers with such that . A reduced residue system modulo is a set of integers
such that each is coprime to , and every integer coprime to is congruent modulo to exactly one . Equivalently, it is a complete set of representatives for the residue classes modulo that consist of integers coprime to . The set of such residue classes, with multiplication induced from ordinary integer multiplication, forms the group of units modulo , denoted ; it has exactly elements.
Intuition
Think of the integers coprime to , reduced modulo , as labeled seats arranged in a circle — a finite, closed universe of residues that never leave the "coprime to " club under multiplication. This closure is the crucial fact: if and , then too, so multiplying two units always gives a unit. Now fix coprime to and ask what happens when you multiply every seat's occupant by , modulo . Because multiplication by is invertible modulo (its inverse being any with ), this operation cannot collide two different seats onto the same value — it must simply shuffle the seats among themselves. Multiplying all occupants together, then, gives the same total product as before the shuffle, just rearranged. Cancelling the common product (which is itself coprime to , hence cancellable) forces . This is the entire proof in miniature: a permutation argument dressed in modular arithmetic. The first figure shows this shuffle concretely for , : the four residues coprime to get permuted by multiplication by .
Because the map merely rearranges , the product equals modulo , and cancelling the common factor (which is invertible mod ) leaves — matching .
Let be a positive integer and let be an integer with . Then
where is Euler's totient function.
Let and let be an integer with . (i) If then . (ii) If then (cancellation).
(i) Since and , by Bézout's identity there are integers with and . Multiplying,
more precisely expanding gives ; concretely,
which exhibits as an integer combination of and . Hence any common divisor of and divides , so .
(ii) Since , Bézout's identity gives integers , with , i.e. ( is a multiplicative inverse of modulo ). If , multiply both sides by :
using .
∎We now prove Euler's Theorem, using the technique of permuting a reduced residue system (the classical argument due to Euler, adapting his own 1758 refinement of Fermat's argument).
Step 1: Fix a reduced residue system. Let and let
be a reduced residue system modulo : representatives, one for each residue class modulo that is coprime to , as given in Reduced Residue Systems and the Totient Function. By definition each satisfies , the are pairwise incongruent modulo , and every integer coprime to is congruent to some .
Step 2: Multiply through by . Since by hypothesis, consider the integers
By part (i) of the Lemma, for each , since both and are coprime to . So each is congruent modulo to some member of the reduced residue system.
Step 3: The new list is again a reduced residue system — no collisions. Suppose for some indices . By part (ii) of the Lemma (cancellation, valid because ), this forces . But the were chosen pairwise incongruent modulo , so . Hence the residues are pairwise incongruent modulo . Since there are exactly of them, all pairwise incongruent, all coprime to , and there are exactly congruence classes coprime to , the set is itself a reduced residue system modulo — indeed it is exactly a rearrangement (a permutation) of . Concretely: the map
is a well-defined bijection (injective by Step 3, and a map from a -element set to itself, hence also surjective).
Step 4: Compare products. Because is a permutation of the indices , multiplying all congruences
together and using that a product of congruences modulo is again a congruence modulo (if for each then , by repeated use of the standard fact that congruences multiply), we get
The right-hand side is a product over all indices in a different order, namely since is a bijection of . So
Step 5: Cancel the common product. Let . Since each is coprime to , repeated application of Lemma (i) shows . The congruence above reads
By Lemma (ii) (cancellation, applicable since ), we cancel from both sides to obtain
This completes the proof. The argument used only: the definition of a reduced residue system, closure of coprimality under multiplication, and cancellation in congruences valid modulo a coprime multiplier — no result depending on Euler's theorem itself was invoked, so the proof is non-circular.
∎If is prime and is any integer with , then
If is prime, every integer is coprime to (since , being prime, shares no factor greater than with any smaller positive integer), and no other residue mod is coprime to except these. Hence . The hypothesis means exactly . Applying Euler's Theorem with gives .
∎Worked examples
Example 1 — reducing a large modular power. Compute . First, , since is prime and does not divide . So Euler's theorem applies with . Compute . Since , use multiplicativity of on prime powers:
By Euler's theorem, . Now reduce the exponent modulo :
Hence
Now compute by repeated squaring:
so remarkably already (the true order of modulo divides and in fact equals — this refinement is the subject of The Order of an Element). Then
So . Note that Euler's theorem alone (using the exact exponent ) already gives a correct, finite computation; the fact that the true period is the smaller number is extra information not supplied by Euler's theorem itself, but consistent with it since .
Example 2 — a modulus with three distinct prime factors. Compute . Factor . Check : is prime and none of divide it, so indeed and Euler's theorem applies. Compute using multiplicativity over the distinct prime factors:
So . Reduce the exponent: , so , giving
Compute by repeated squaring, reducing mod at every step:
Now write , so
So . As a check via the Chinese Remainder Theorem: modulo , , and so ; indeed . Modulo , , , so ; indeed . Modulo , , , so ; indeed . All three checks agree with , confirming the answer.
Euler's theorem requires . Drop this hypothesis and the conclusion can fail outright. Take (so ) and , which shares the factor with , so . Euler's theorem's conclusion would assert . But directly, . The congruence fails. More strongly, no power of is ever congruent to : every power of is even, while any integer congruent to is odd (since is odd for every integer ). So the failure is not a near miss — it is structural. The reason the proof breaks down is precise: Step 3 used cancellation "," which relied on having a multiplicative inverse modulo , which in turn required via Bézout's identity. Without that hypothesis, multiplication by need not be injective on residues modulo , the "shuffle" argument collapses, and no version of the conclusion is guaranteed. This shows the hypothesis is not a technical nicety but load-bearing in the proof.
Scope, edge cases & common traps
| Situation | What happens |
|---|---|
| by convention (the empty product / single residue class itself is "coprime" vacuously); every integer satisfies trivially, since everything is everything mod . | |
| prime | Recovers Fermat's Little Theorem exactly, since . |
| Theorem simply does not apply; conclusion can fail, as shown above. | |
| Exponent smaller than also works | Common: the actual smallest exponent with (the order of ) always divides , but can be strictly smaller, as seen with despite . |
| Negative or zero exponent | Euler's theorem is stated for exponent ; extending to negative exponents requires interpreting as the modular inverse, which exists precisely because . |
| Reducing huge exponents in computations | Correct only when the base is coprime to the modulus — reduce the exponent modulo , not modulo . |
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Leonhard Euler was among the most prolific mathematicians in history, contributing foundational results across analysis, mechanics, graph theory, and number theory. Working largely by correspondence with Christian Goldbach, Euler took up Fermat's scattered, often unproved claims about primes and congruences and turned them into a systematic theory. His 1763 memoir generalized Fermat's Little Theorem to composite moduli by introducing what is now called the totient function, proving the theorem that bears his name using the permutation-of-residues argument reproduced above. Euler continued working prolifically even after losing most of his eyesight later in life, dictating calculations to assistants.
Why is Euler's theorem considered a generalization of Fermat's Little Theorem?
Fermat's Little Theorem states that for a prime and any integer not divisible by , . Euler's theorem replaces the prime modulus with an arbitrary positive integer and replaces the exponent with . When is prime, every integer from to is coprime to , so exactly, and Euler's statement becomes word-for-word Fermat's statement. Thus Fermat's theorem is the special case of Euler's theorem restricted to prime moduli, and Euler's theorem is the natural extension covering all composite moduli as well, using the totient count instead of .
Does Euler's theorem tell us the smallest exponent that works?
No. Euler's theorem only guarantees that for some specific exponent, namely ; it does not claim this is the smallest such exponent. The smallest positive integer with is called the order of modulo , and one can prove always divides . Sometimes exactly (then is called a primitive root), but often is a proper divisor, as in the example even though . This finer question is the subject of the theory of the order of an element.
What role does the coprimality condition gcd(a,n) = 1 actually play in the proof?
It guarantees that has a multiplicative inverse modulo , via Bézout's identity. This inverse is what makes multiplication by a bijection (an injective map on a finite set, hence a permutation) on the reduced residue system modulo . Without this bijectivity, the key step of the proof — that multiplying every element of the reduced residue system by just rearranges it — collapses, since two different residues could then collide to the same product modulo . The coprimality condition is not a mere technicality; it is precisely what makes the permutation argument valid.
How is Euler's theorem used in RSA encryption?
RSA chooses two large primes , sets , and computes . A public encryption exponent and private decryption exponent are chosen so that . For a message coprime to , encryption computes and decryption computes . Since for some integer , Euler's theorem gives , recovering the original message. This is the precise mechanism by which Euler's theorem makes RSA decryption correct.
Can Euler's theorem be extended to messages or bases not coprime to n?
The theorem as stated requires and can genuinely fail otherwise, as shown in the counterexample with , . However, a related and more delicate result (sometimes attributed to Euler's successors, refined via the Carmichael function or handled case-by-case using the Chinese Remainder Theorem) shows that for RSA-type moduli with distinct primes, the congruence still holds for all integers , coprime to or not, provided . This extension uses Fermat's Little Theorem directly modulo each prime factor rather than Euler's theorem modulo the composite , and is a separate (though related) argument.
What is the group-theoretic meaning of Euler's theorem?
The integers coprime to , taken modulo , form a finite group under multiplication, called the group of units , with exactly elements. A basic fact in finite group theory, Lagrange's theorem, states that the order of any element of a finite group divides the order of the group itself. Applying this to the group of units immediately gives that the order of (the smallest with ) divides , and in particular . Euler's theorem can thus be seen as the number-theoretic incarnation of this purely algebraic fact, discovered decades before group theory itself was formalized.
Why does the proof fail to be circular, and what exactly does it assume?
The proof assumes only prior facts about reduced residue systems (their existence and size , from Reduced Residue Systems and the Totient Function), basic properties of congruences (that they respect multiplication), and Bézout's identity from elementary divisibility theory. None of these facts depend on Euler's theorem itself, nor on Fermat's Little Theorem, which is instead derived as a corollary afterward. This ordering — building from more elementary, independently established facts up to the theorem — is what makes the proof logically sound and non-circular.