Euler's Theorem

How does a computer decide, in a fraction of a second, that 72019  100=437^{2019} \bmod 100 = 43? It never computes the astronomically large number 720197^{2019}. 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 nn to the power φ(n)\varphi(n) — Euler's totient — always returns 11 modulo nn. 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 nn 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 φ(n)\varphi(n) (or a close relative of it) without changing the answer modulo nn. Beyond applications, Euler's theorem is a paradigm example of something deeper. It shows how group structure — here, the group of units modulo nn — 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 nn that are coprime to nn form a finite abelian group under multiplication. This is the group of units (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^{\times}, of order φ(n)\varphi(n). 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.

Key takeaways
  • Euler's theorem: if gcd⁡(a,n)=1\gcd(a,n)=1 then aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod{n}.
  • It generalizes Fermat's Little Theorem, which is the case n=pn=p prime, since φ(p)=p−1\varphi(p) = p-1.
  • The proof permutes a reduced residue system by multiplication by aa and compares products.
  • It reduces modular exponentiation with huge exponents to a computation modulo φ(n)\varphi(n).
  • Coprimality gcd⁡(a,n)=1\gcd(a,n)=1 is essential; without it the congruence can fail entirely.
  • Key idea: the units modulo nn form a group of order φ(n)\varphi(n), 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 11 modulo φ(n)\varphi(n) (for an RSA modulus n=pqn = pq), guaranteeing via Euler's theorem that decryption recovers the original message modulo nn, for any message coprime to nn. The theorem is also the reason why modular exponentiation algorithms used throughout cryptography and computer algebra systems can safely reduce huge exponents modulo φ(n)\varphi(n) 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 (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^{\times}: the order of any element of a finite group divides the order of the group, and here "order of the group" is exactly φ(n)\varphi(n). 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 an−1≡1(modn)a^{n-1}\equiv 1 \pmod n (or refined variants) for random bases aa 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 nn 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?

DefinitionEuler's totient function and reduced residue systems

For a positive integer nn, Euler's totient function φ(n)\varphi(n) counts the integers kk with 1≤k≤n1 \le k \le n such that gcd⁡(k,n)=1\gcd(k,n) = 1. A reduced residue system modulo nn is a set of φ(n)\varphi(n) integers

r1,r2,…,rφ(n)r_1, r_2, \dots, r_{\varphi(n)}

such that each rir_i is coprime to nn, and every integer coprime to nn is congruent modulo nn to exactly one rir_i. Equivalently, it is a complete set of representatives for the residue classes modulo nn that consist of integers coprime to nn. The set of such residue classes, with multiplication induced from ordinary integer multiplication, forms the group of units modulo nn, denoted (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^{\times}; it has exactly φ(n)\varphi(n) elements.

Intuition

Think of the integers coprime to nn, reduced modulo nn, as φ(n)\varphi(n) labeled seats arranged in a circle — a finite, closed universe of residues that never leave the "coprime to nn" club under multiplication. This closure is the crucial fact: if gcd⁡(a,n)=1\gcd(a,n)=1 and gcd⁡(b,n)=1\gcd(b,n)=1, then gcd⁡(ab,n)=1\gcd(ab,n)=1 too, so multiplying two units always gives a unit. Now fix aa coprime to nn and ask what happens when you multiply every seat's occupant by aa, modulo nn. Because multiplication by aa is invertible modulo nn (its inverse being any a′a' with aa′≡1aa' \equiv 1), this operation cannot collide two different seats onto the same value — it must simply shuffle the seats among themselves. Multiplying all φ(n)\varphi(n) occupants together, then, gives the same total product as before the shuffle, just rearranged. Cancelling the common product (which is itself coprime to nn, hence cancellable) forces aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod n. This is the entire proof in miniature: a permutation argument dressed in modular arithmetic. The first figure shows this shuffle concretely for n=10n = 10, a=3a = 3: the four residues coprime to 1010 get permuted by multiplication by 33.

Figure
Multiplication by a=3a=3 permutes the reduced residue system mod 1010: {1,3,7,9}\{1,3,7,9\}
Reduced residue system mod 10: {1, 3, 7, 9}, φ(10) = 4 1 3 7 9 3 9 1 7 ×3 mod 10 3·9=27≡7

Because the map x↦3x  10x \mapsto 3x \bmod 10 merely rearranges {1,3,7,9}\{1,3,7,9\}, the product 1⋅3⋅7⋅91\cdot3\cdot7\cdot9 equals (3⋅1)(3⋅3)(3⋅7)(3⋅9)(3\cdot1)(3\cdot3)(3\cdot7)(3\cdot9) modulo 1010, and cancelling the common factor 1⋅3⋅7⋅9≡189≡91\cdot3\cdot7\cdot9 \equiv 189 \equiv 9 (which is invertible mod 1010) leaves 34≡1(mod10)3^4 \equiv 1 \pmod{10} — matching φ(10)=4\varphi(10)=4.

TheoremEuler's Theorem

Let nn be a positive integer and let aa be an integer with gcd⁡(a,n)=1\gcd(a,n) = 1. Then

aφ(n)≡1(modn),a^{\varphi(n)} \equiv 1 \pmod{n},

where φ\varphi is Euler's totient function.

LemmaClosure and cancellation among units

Let n≥1n \ge 1 and let aa be an integer with gcd⁡(a,n)=1\gcd(a,n)=1. (i) If gcd⁡(b,n)=1\gcd(b,n)=1 then gcd⁡(ab,n)=1\gcd(ab,n)=1. (ii) If ax≡ay(modn)ax \equiv ay \pmod n then x≡y(modn)x \equiv y \pmod n (cancellation).

Proof

(i) Since gcd⁡(a,n)=1\gcd(a,n)=1 and gcd⁡(b,n)=1\gcd(b,n)=1, by Bézout's identity there are integers u,v,s,tu,v,s,t with au+nv=1au+nv=1 and bs+nt=1bs+nt=1. Multiplying,

(au+nv)(bs+nt)=1  ⟹  ab(us)+n(uvt′)=1(au+nv)(bs+nt) = 1 \implies ab(us) + n(uvt' ) = 1

more precisely expanding gives ab(us)+n(u⋅t⋅a⋅(rearranged terms)+v⋅bs+vnt)=1ab(us) + n(u \cdot t \cdot a \cdot \text{(rearranged terms)} + v \cdot bs + v n t) = 1; concretely,

1=(au+nv)(bs+nt)=ab(us)+n(aut+vbs+vnt),1 = (au+nv)(bs+nt) = ab(us) + n\big(a u t + v b s + v n t\big),

which exhibits 11 as an integer combination of abab and nn. Hence any common divisor of abab and nn divides 11, so gcd⁡(ab,n)=1\gcd(ab,n)=1.

(ii) Since gcd⁡(a,n)=1\gcd(a,n)=1, Bézout's identity gives integers a′a', mm with aa′+nm=1aa' + nm = 1, i.e. aa′≡1(modn)aa' \equiv 1 \pmod n (a′a' is a multiplicative inverse of aa modulo nn). If ax≡ay(modn)ax \equiv ay \pmod n, multiply both sides by a′a':

a′ax≡a′ay(modn)  ⟹  x≡y(modn),a'ax \equiv a'ay \pmod n \implies x \equiv y \pmod n,

using a′a≡1(modn)a'a \equiv 1 \pmod n. ■\blacksquare

∎
Proof

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 φ(n)=k\varphi(n) = k and let

r1,r2,…,rkr_1, r_2, \dots, r_k

be a reduced residue system modulo nn: representatives, one for each residue class modulo nn that is coprime to nn, as given in Reduced Residue Systems and the Totient Function. By definition each rir_i satisfies gcd⁡(ri,n)=1\gcd(r_i, n) = 1, the rir_i are pairwise incongruent modulo nn, and every integer coprime to nn is congruent to some rir_i.

Step 2: Multiply through by aa. Since gcd⁡(a,n)=1\gcd(a,n) = 1 by hypothesis, consider the kk integers

ar1, ar2, …, ark.ar_1,\ ar_2,\ \dots,\ ar_k.

By part (i) of the Lemma, gcd⁡(ari,n)=1\gcd(a r_i, n) = 1 for each ii, since both aa and rir_i are coprime to nn. So each ariar_i is congruent modulo nn to some member of the reduced residue system.

Step 3: The new list is again a reduced residue system — no collisions. Suppose ari≡arj(modn)a r_i \equiv a r_j \pmod n for some indices i,ji, j. By part (ii) of the Lemma (cancellation, valid because gcd⁡(a,n)=1\gcd(a,n)=1), this forces ri≡rj(modn)r_i \equiv r_j \pmod n. But the rir_i were chosen pairwise incongruent modulo nn, so i=ji = j. Hence the kk residues ar1,…,ark(modn)ar_1, \dots, ar_k \pmod n are pairwise incongruent modulo nn. Since there are exactly k=φ(n)k = \varphi(n) of them, all pairwise incongruent, all coprime to nn, and there are exactly φ(n)\varphi(n) congruence classes coprime to nn, the set {ar1  n,…,ark  n}\{ar_1 \bmod n, \dots, ar_k \bmod n\} is itself a reduced residue system modulo nn — indeed it is exactly a rearrangement (a permutation) of {r1  n,…,rk  n}\{r_1 \bmod n, \dots, r_k \bmod n\}. Concretely: the map

σ:{r1,…,rk}→{r1,…,rk}(modn),σ(ri)=the unique rj with ari≡rj(modn)\sigma : \{r_1,\dots,r_k\} \to \{r_1,\dots,r_k\} \pmod n, \qquad \sigma(r_i) = \text{the unique } r_j \text{ with } ar_i \equiv r_j \pmod n

is a well-defined bijection (injective by Step 3, and a map from a kk-element set to itself, hence also surjective).

Step 4: Compare products. Because σ\sigma is a permutation of the indices {1,…,k}\{1,\dots,k\}, multiplying all kk congruences

ari≡rσ(i)(modn),i=1,…,ka r_i \equiv r_{\sigma(i)} \pmod n, \qquad i = 1,\dots,k

together and using that a product of congruences modulo nn is again a congruence modulo nn (if xi≡yi(modn)x_i \equiv y_i \pmod n for each ii then ∏xi≡∏yi(modn)\prod x_i \equiv \prod y_i \pmod n, by repeated use of the standard fact that congruences multiply), we get

∏i=1k(ari)≡∏i=1krσ(i)(modn).\prod_{i=1}^{k} (a r_i) \equiv \prod_{i=1}^{k} r_{\sigma(i)} \pmod n.

The right-hand side is a product over all indices 1,…,k1,\dots,k in a different order, namely ∏i=1krσ(i)=∏j=1krj\prod_{i=1}^k r_{\sigma(i)} = \prod_{j=1}^k r_j since σ\sigma is a bijection of {1,…,k}\{1,\dots,k\}. So

ak∏i=1kri≡∏i=1kri(modn).a^{k} \prod_{i=1}^{k} r_i \equiv \prod_{i=1}^{k} r_i \pmod n.

Step 5: Cancel the common product. Let R=∏i=1kriR = \prod_{i=1}^k r_i. Since each rir_i is coprime to nn, repeated application of Lemma (i) shows gcd⁡(R,n)=1\gcd(R, n) = 1. The congruence above reads

akR≡1⋅R(modn).a^k R \equiv 1 \cdot R \pmod n.

By Lemma (ii) (cancellation, applicable since gcd⁡(R,n)=1\gcd(R,n)=1), we cancel RR from both sides to obtain

ak≡1(modn),i.e.aφ(n)≡1(modn).a^{k} \equiv 1 \pmod{n}, \qquad \text{i.e.} \qquad a^{\varphi(n)} \equiv 1 \pmod n.

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. ■\blacksquare

∎
CorollaryFermat's Little Theorem as a special case

If pp is prime and aa is any integer with p∤ap \nmid a, then

ap−1≡1(modp).a^{p-1} \equiv 1 \pmod p.
Proof

If pp is prime, every integer 1,2,…,p−11, 2, \dots, p-1 is coprime to pp (since pp, being prime, shares no factor greater than 11 with any smaller positive integer), and no other residue mod pp is coprime to pp except these. Hence φ(p)=p−1\varphi(p) = p - 1. The hypothesis p∤ap \nmid a means exactly gcd⁡(a,p)=1\gcd(a,p) = 1. Applying Euler's Theorem with n=pn = p gives aφ(p)=ap−1≡1(modp)a^{\varphi(p)} = a^{p-1} \equiv 1 \pmod p. ■\blacksquare

∎

Worked examples

Example 1 — reducing a large modular power. Compute 72019  1007^{2019} \bmod 100. First, gcd⁡(7,100)=1\gcd(7,100) = 1, since 77 is prime and does not divide 100=22⋅52100 = 2^2 \cdot 5^2. So Euler's theorem applies with n=100n = 100. Compute φ(100)\varphi(100). Since 100=22⋅52100 = 2^2 \cdot 5^2, use multiplicativity of φ\varphi on prime powers:

φ(100)=φ(22)φ(52)=(22−21)(52−51)=(4−2)(25−5)=2⋅20=40.\varphi(100) = \varphi(2^2)\varphi(5^2) = \big(2^2 - 2^1\big)\big(5^2 - 5^1\big) = (4-2)(25-5) = 2 \cdot 20 = 40.

By Euler's theorem, 740≡1(mod100)7^{40} \equiv 1 \pmod{100}. Now reduce the exponent 20192019 modulo 4040:

2019=40⋅50+19,so2019≡19(mod40).2019 = 40 \cdot 50 + 19, \qquad \text{so} \qquad 2019 \equiv 19 \pmod{40}.

Hence

72019=740⋅50+19=(740)50⋅719≡150⋅719≡719(mod100).7^{2019} = 7^{40 \cdot 50 + 19} = \big(7^{40}\big)^{50} \cdot 7^{19} \equiv 1^{50}\cdot 7^{19} \equiv 7^{19} \pmod{100}.

Now compute 719  1007^{19} \bmod 100 by repeated squaring:

71=7,72=49,74=492=2401≡1(mod100),7^1 = 7,\qquad 7^2 = 49,\qquad 7^4 = 49^2 = 2401 \equiv 1 \pmod{100},

so remarkably 74≡1(mod100)7^4 \equiv 1 \pmod{100} already (the true order of 77 modulo 100100 divides 4040 and in fact equals 44 — this refinement is the subject of The Order of an Element). Then

19=4⋅4+3  ⟹  719=(74)4⋅73≡14⋅343≡343  100≡43.19 = 4\cdot 4 + 3 \implies 7^{19} = (7^4)^4 \cdot 7^3 \equiv 1^4 \cdot 343 \equiv 343 \bmod 100 \equiv 43.

So 72019≡43(mod100)7^{2019} \equiv 43 \pmod{100}. Note that Euler's theorem alone (using the exact exponent φ(100)=40\varphi(100)=40) already gives a correct, finite computation; the fact that the true period is the smaller number 44 is extra information not supplied by Euler's theorem itself, but consistent with it since 4∣404 \mid 40.

Example 2 — a modulus with three distinct prime factors. Compute 17500  10517^{500} \bmod 105. Factor 105=3⋅5⋅7105 = 3 \cdot 5 \cdot 7. Check gcd⁡(17,105)=1\gcd(17,105)=1: 1717 is prime and none of 3,5,73,5,7 divide it, so indeed gcd⁡(17,105)=1\gcd(17,105)=1 and Euler's theorem applies. Compute φ(105)\varphi(105) using multiplicativity over the distinct prime factors:

φ(105)=φ(3)φ(5)φ(7)=2⋅4⋅6=48.\varphi(105) = \varphi(3)\varphi(5)\varphi(7) = 2 \cdot 4 \cdot 6 = 48.

So 1748≡1(mod105)17^{48} \equiv 1 \pmod{105}. Reduce the exponent: 500=48⋅10+20500 = 48 \cdot 10 + 20, so 500≡20(mod48)500 \equiv 20 \pmod{48}, giving

17500≡1720(mod105).17^{500} \equiv 17^{20} \pmod{105}.

Compute 1720  10517^{20} \bmod 105 by repeated squaring, reducing mod 105105 at every step:

171=17,17^1 = 17,
172=289=2⋅105+79≡79(mod105),17^2 = 289 = 2\cdot 105 + 79 \equiv 79 \pmod{105},
174≡792=6241=59⋅105+46≡46(mod105),17^4 \equiv 79^2 = 6241 = 59\cdot 105 + 46 \equiv 46 \pmod{105},
178≡462=2116=20⋅105+16≡16(mod105),17^8 \equiv 46^2 = 2116 = 20\cdot 105 + 16 \equiv 16 \pmod{105},
1716≡162=256=2⋅105+46≡46(mod105).17^{16} \equiv 16^2 = 256 = 2\cdot 105 + 46 \equiv 46 \pmod{105}.

Now write 20=16+420 = 16 + 4, so

1720=1716⋅174≡46⋅46=2116≡16(mod105).17^{20} = 17^{16}\cdot 17^{4} \equiv 46 \cdot 46 = 2116 \equiv 16 \pmod{105}.

So 17500≡16(mod105)17^{500} \equiv 16 \pmod{105}. As a check via the Chinese Remainder Theorem: modulo 33, 17≡217\equiv 2, and φ(3)=2\varphi(3)=2 so 2500=22⋅250≡1(mod3)2^{500}=2^{2\cdot250}\equiv 1 \pmod 3; indeed 16≡1(mod3)16 \equiv 1 \pmod 3. Modulo 55, 17≡217\equiv 2, φ(5)=4\varphi(5)=4, 500≡0(mod4)500 \equiv 0 \pmod 4 so 2500≡1(mod5)2^{500}\equiv 1\pmod 5; indeed 16≡1(mod5)16\equiv 1\pmod 5. Modulo 77, 17≡317 \equiv 3, φ(7)=6\varphi(7)=6, 500=6⋅83+2500 = 6\cdot83+2 so 3500≡32=9≡2(mod7)3^{500}\equiv 3^2=9\equiv 2\pmod 7; indeed 16≡2(mod7)16 \equiv 2 \pmod 7. All three checks agree with 16  10516 \bmod 105, confirming the answer.

Counterexampledropping the coprimality hypothesis gcd⁡(a,n)=1\gcd(a,n)=1

Euler's theorem requires gcd⁡(a,n)=1\gcd(a,n) = 1. Drop this hypothesis and the conclusion can fail outright. Take n=6n = 6 (so φ(6)=φ(2)φ(3)=1⋅2=2\varphi(6) = \varphi(2)\varphi(3) = 1\cdot 2 = 2) and a=2a = 2, which shares the factor 22 with n=6n=6, so gcd⁡(2,6)=2≠1\gcd(2,6) = 2 \ne 1. Euler's theorem's conclusion would assert 2φ(6)=22=4≡1(mod6)2^{\varphi(6)} = 2^2 = 4 \equiv 1 \pmod 6. But directly, 4  6=4≠14 \bmod 6 = 4 \ne 1. The congruence fails. More strongly, no power of 22 is ever congruent to 1(mod6)1 \pmod 6: every power of 22 is even, while any integer congruent to 1(mod6)1 \pmod 6 is odd (since 1+6k1 + 6k is odd for every integer kk). So the failure is not a near miss — it is structural. The reason the proof breaks down is precise: Step 3 used cancellation "ari≡arj(modn)  ⟹  ri≡rjar_i \equiv ar_j \pmod n \implies r_i \equiv r_j," which relied on aa having a multiplicative inverse modulo nn, which in turn required gcd⁡(a,n)=1\gcd(a,n)=1 via Bézout's identity. Without that hypothesis, multiplication by aa need not be injective on residues modulo nn, the "shuffle" argument collapses, and no version of the conclusion is guaranteed. This shows the hypothesis gcd⁡(a,n)=1\gcd(a,n)=1 is not a technical nicety but load-bearing in the proof.

Scope, edge cases & common traps

SituationWhat happens
n=1n = 1φ(1)=1\varphi(1) = 1 by convention (the empty product / single residue class 0≡0 \equiv itself is "coprime" vacuously); every integer aa satisfies a1≡1(mod1)a^1 \equiv 1 \pmod 1 trivially, since everything is ≡0≡\equiv 0 \equiv everything mod 11.
n=pn = p primeRecovers Fermat's Little Theorem exactly, since φ(p)=p−1\varphi(p) = p-1.
gcd⁡(a,n)≠1\gcd(a,n) \ne 1Theorem simply does not apply; conclusion can fail, as shown above.
Exponent smaller than φ(n)\varphi(n) also worksCommon: the actual smallest exponent dd with ad≡1(modn)a^d \equiv 1 \pmod n (the order of aa) always divides φ(n)\varphi(n), but can be strictly smaller, as seen with 74≡1(mod100)7^4\equiv 1 \pmod{100} despite φ(100)=40\varphi(100)=40.
Negative or zero exponentEuler's theorem is stated for exponent φ(n)≥1\varphi(n) \geq 1; extending to negative exponents requires interpreting a−1a^{-1} as the modular inverse, which exists precisely because gcd⁡(a,n)=1\gcd(a,n)=1.
Reducing huge exponents in computationsCorrect only when the base is coprime to the modulus — reduce the exponent modulo φ(n)\varphi(n), not modulo nn.

The mathematician behind it

Origins · 1 minLeonhard Euler and how this was discovered
LE
Leonhard Euler
1707–1783 · Basel, Switzerland; Berlin and St. Petersburg Academies

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.

History
- 1640: Pierre de Fermat states, without a surviving proof, the special case for prime moduli — Fermat's Little Theorem.
- 1736: Euler publishes the first known proof of Fermat's Little Theorem.
- 1760: Euler introduces the totient function φ(n)\varphi(n) in the course of generalizing Fermat's result to composite moduli.
- 1763: Euler publishes the full generalization, aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod n for gcd⁡(a,n)=1\gcd(a,n)=1, now called Euler's theorem.
- 1801: Carl Friedrich Gauss, in Disquisitiones Arithmeticae, systematizes congruence notation and reproves Euler's theorem within a broader theory of residues, cementing its modern form.
Why is Euler's theorem considered a generalization of Fermat's Little Theorem?

Fermat's Little Theorem states that for a prime pp and any integer aa not divisible by pp, ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p. Euler's theorem replaces the prime modulus pp with an arbitrary positive integer nn and replaces the exponent p−1p-1 with φ(n)\varphi(n). When n=pn=p is prime, every integer from 11 to p−1p-1 is coprime to pp, so φ(p)=p−1\varphi(p) = p-1 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 p−1p-1.

Does Euler's theorem tell us the smallest exponent that works?

No. Euler's theorem only guarantees that aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod n for some specific exponent, namely φ(n)\varphi(n); it does not claim this is the smallest such exponent. The smallest positive integer dd with ad≡1(modn)a^{d} \equiv 1 \pmod n is called the order of aa modulo nn, and one can prove dd always divides φ(n)\varphi(n). Sometimes d=φ(n)d = \varphi(n) exactly (then aa is called a primitive root), but often dd is a proper divisor, as in the example 74≡1(mod100)7^4 \equiv 1 \pmod{100} even though φ(100)=40\varphi(100) = 40. 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 aa has a multiplicative inverse modulo nn, via Bézout's identity. This inverse is what makes multiplication by aa a bijection (an injective map on a finite set, hence a permutation) on the reduced residue system modulo nn. Without this bijectivity, the key step of the proof — that multiplying every element of the reduced residue system by aa just rearranges it — collapses, since two different residues could then collide to the same product modulo nn. 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 p,qp, q, sets n=pqn = pq, and computes φ(n)=(p−1)(q−1)\varphi(n) = (p-1)(q-1). A public encryption exponent ee and private decryption exponent dd are chosen so that ed≡1(modφ(n))ed \equiv 1 \pmod{\varphi(n)}. For a message mm coprime to nn, encryption computes c=me  nc = m^e \bmod n and decryption computes cd  nc^d \bmod n. Since ed=1+kφ(n)ed = 1 + k\varphi(n) for some integer kk, Euler's theorem gives cd=med=m⋅(mφ(n))k≡m⋅1k=m(modn)c^d = m^{ed} = m \cdot (m^{\varphi(n)})^{k} \equiv m \cdot 1^{k} = m \pmod n, 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 gcd⁡(a,n)=1\gcd(a,n)=1 and can genuinely fail otherwise, as shown in the counterexample with a=2a=2, n=6n=6. 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 n=pqn=pq with distinct primes, the congruence med≡m(modn)m^{ed}\equiv m \pmod n still holds for all integers mm, coprime to nn or not, provided ed≡1(modlcm⁡(p−1,q−1))ed \equiv 1 \pmod{\operatorname{lcm}(p-1,q-1)}. This extension uses Fermat's Little Theorem directly modulo each prime factor rather than Euler's theorem modulo the composite nn, and is a separate (though related) argument.

What is the group-theoretic meaning of Euler's theorem?

The integers coprime to nn, taken modulo nn, form a finite group under multiplication, called the group of units (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^{\times}, with exactly φ(n)\varphi(n) 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 aa (the smallest dd with ad≡1a^d\equiv 1) divides φ(n)\varphi(n), and in particular aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod n. 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 φ(n)\varphi(n), 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.

Before this