Eulers Theorem

Eulers Theorem

Eulers theorem is a fundamental result in number theory that generalizes Fermats little theorem. It establishes a relationship between modular exponentiation and the totient function, with profound applications in cryptography and computational number theory.

Named after Leonhard Euler, this theorem is the mathematical foundation underlying the RSA cryptosystem.

The Euler Totient Function

Before stating the theorem, we need the Euler totient function ϕ⁡(n) phi of n, which counts the positive integers up to n n that are relatively prime to n n:

ϕ⁡(n)=|{k:1≤k≤n,gcd⁡(k,n)=1}| phi of n equals the absolute value of open brace k colon 1 is less than or equal to k is less than or equal to n comma the gcd of open paren k comma n close paren equals 1 close brace

Examples

φ⁡(1)=1 phi of 1 equals 1 (only 1 1 is counted)

φ⁡(6)=2 phi of 6 equals 2 (only 1 1 and 5 5 are coprime to 6 6)

φ⁡(7)=6 phi of 7 equals 6 (all of 1 1, 2 2, 3 3, 4 4, 5 5, 6 6 are coprime to the prime 7 7)

φ⁡(10)=4 phi of 10 equals 4 (the numbers 1 1, 3 3, 7 7, 9 9 are coprime to 10 10)

Formula for Totient

For a prime p p:

ϕ⁡(p)=p−1 phi of p equals p minus 1

For a prime power:

ϕ⁡(pk)=pk−pk−1=pk−1⁢(p−1) phi of open paren p to the k-th power close paren equals p to the k-th power minus p raised to the k minus 1 power equals p raised to the k minus 1 power times open paren p minus 1 close paren

For coprime integers m and n, the totient is multiplicative:

ϕ⁡(m⁢n)=ϕ⁡(m)⁢ϕ⁡(n)when gcd⁡(m,n)=1 phi of m n equals phi of m phi of n when the gcd of open paren m comma n close paren equals 1

Using the prime factorization, we get the general formula:

ϕ⁡(n)=n⁢∏p|n(1−1p) phi of n equals n the product over p divides n of open paren 1 minus 1 over p close paren

Statement of Eulers Theorem

Theorem: If a a and n n are positive integers with gcd⁡(a,n)=1 the gcd of open paren a comma n close paren equals 1, then:

aφ⁡(n)≡1⁢(mod⁡(n)) a raised to the phi of n power is identical to 1 times mod n

In words: if a a is coprime to n n, then a a raised to the power φ⁡(n) phi of n leaves remainder 1 1 when divided by n n.

Proof Outline

The proof uses the group of units modulo n n. Let U⁡(n) U of n be the set of integers between 1 1 and n n that are coprime to n n. This forms a group under multiplication modulo n n, with |U⁡(n)|=φ⁡(n) the absolute value of U of n equals phi of n.

Consider the map x↦a⁢x⁢(mod⁡(n)) x right arrow from bar a x times mod n on U⁡(n) U of n. Since gcd⁡(a,n)=1 the gcd of open paren a comma n close paren equals 1this is a bijection. Therefore:

∏x∈U⁡(n)a⁢x≡∏x∈U⁡(n)(x)⁢(mod⁡(n)) the product over x is a member of U of n of a x is identical to the product over x is a member of U of n of x times mod n

The left side equals a a to the ϕ⁡(n) phi of n times the product of all x x. Canceling the product from both sides (valid since each x x is coprime to n) n close paren gives:

aϕ⁡(n)≡1⁢(mod⁡(n)) a raised to the phi of n power is identical to 1 times mod n

Fermats Little Theorem as a Special Case

When n=p n equals p is prime, ϕ⁡(p)=p-1 phi of p equals p minus 1, and Eulers theorem becomes Fermats little theorem:

ap−1≡1⁢(mod⁡(p)) a raised to the p minus 1 power is identical to 1 times mod p for gcd⁡(a,p)=1 the gcd of open paren a comma p close paren equals 1

Equivalently, for any integer a a:

ap≡a⁢(mod⁡(p)) a to the p-th power is identical to a times mod p

This version holds even when a a is divisible by p p.

Applications

Computing Modular Inverses

If g⁢c⁢d⁡(a,n)=1 g c d of open paren a comma n close paren equals 1, then a has a multiplicative inverse modulo n n. From Eulers theorem:

a⋅aϕ⁡(n)−1≡1⁢(mod⁡(n)) a times a raised to the phi of n minus 1 power is identical to 1 times mod n

So the inverse of a modulo n n is a to the power ϕ⁡(n)-1 phi of n minus 1. This provides one method for computing modular inverses.

RSA Cryptography

The RSA algorithm uses Euler's theorem directly. Given n=p⁢q n equals p q (product of two large primes), we have φ⁡(n)=(p−1)⁢(q−1) phi of n equals open paren p minus 1 close paren times open paren q minus 1 close paren. Public and private keys e e and d d satisfy:

e⁢d≡1⁢(mod⁡(ϕ⁡(n))) e d is identical to 1 times mod phi of n

For any message m m with g⁢c⁢d⁡(m,n)=1 g c d of open paren m comma n close paren equals 1, encryption and decryption work because:

(me)d=me⁢d=m1+k⁢ϕ⁡(n)=m⋅(mϕ⁡(n))k≡m⁢(mod⁡(n)) m to the e-th power to the d-th power equals m raised to the e d power equals m raised to the 1 plus k phi of n power equals m times m raised to the phi of n power to the k-th power is identical to m times mod n

Reducing Large Exponents

Eulers theorem allows us to reduce exponents in modular arithmetic. To compute a a to a large power k k modulo n n:

ak≡ak⁢mod⁡(ϕ⁡(n))⁢(mod⁡(n)) a to the k-th power is identical to a raised to the k mod phi of n power times mod n

This dramatically simplifies computations with very large exponents.

Carmichael Function

The Carmichael function λ⁡(n) lamda of n is the smallest positive integer m m such that am≡1⁢(mod⁡(n)) a to the m-th power is identical to 1 times mod n for all a a coprime to n n. It divides φ⁡(n) phi of n and often equals it, but can be smaller.

For example, λ⁡(8)=2 lamda of 8 equals 2 while φ⁡(8)=4 phi of 8 equals 4. The Carmichael function provides the tightest bound for the exponent in modular arithmetic.

Generalizations

Euler's theorem can be generalized in several ways. For any group G G, the order of any element divides the order of the group. When G G is the group of units modulo n n, this gives Euler's theorem.

The theorem also extends to polynomial rings and other algebraic structures, forming part of the broader theory of groups and rings.

Computing the Totient Function

To compute φ⁡(n) phi of n, first find the prime factorization n=p1a1⁢p2a2⋯ n equals p sub 1 raised to the a sub 1 power p sub 2 raised to the a sub 2 power dot dot dot. Then:

ϕ⁡(n)=∏i(piai−1)⁢(pi−1)=n⁢∏p|n(1−1p) phi of n equals the product over i of open paren p sub i raised to the a sub i minus 1 power close paren times open paren p sub i minus 1 close paren equals n the product over p divides n of open paren 1 minus 1 over p close paren

For example, phi(12) = phi(4) times phi(3) = 2 times 2 = 4, or equivalently 12 times (1 - 1/2) times (1 - 1/3) = 12 times 1/2 times 2/3 = 4.

Historical Note

Euler published this theorem in 1763, generalizing Fermats little theorem from 1640. The proof demonstrates Eulers mastery of combining algebraic and number-theoretic ideas.

The theorem remains central to computational number theory and is one of the most practically important results in mathematics, securing trillions of dollars in electronic transactions through its role in RSA encryption.