Skip to content

Euler Totient Function

Euler's totient function is an arithmetic function denoted by

Counting Coprime Residues

Euler’s totient function is an arithmetic function denoted by

φ(n). \varphi(n).

For a positive integer nn, it counts the integers aa satisfying

1an 1\le a\le n

and

gcd(a,n)=1. \gcd(a,n)=1.

Thus

φ(n)=#{a:1an, gcd(a,n)=1}. \varphi(n)=\#\{a:1\le a\le n,\ \gcd(a,n)=1\}.

For example, the integers from 11 to 1010 that are coprime to 1010 are

1,3,7,9. 1,3,7,9.

Therefore

φ(10)=4. \varphi(10)=4.

The totient function measures how many residue classes modulo nn are invertible.

Prime Moduli

If pp is prime, then every integer

1,2,,p1 1,2,\ldots,p-1

is coprime to pp, while pp itself is not. Therefore

φ(p)=p1. \varphi(p)=p-1.

For example,

φ(7)=6. \varphi(7)=6.

This corresponds to the fact that modulo a prime pp, every nonzero residue class has a multiplicative inverse.

Prime Powers

Let pp be prime and let α1\alpha\ge1. We compute

φ(pα). \varphi(p^\alpha).

Among the integers

1,2,,pα, 1,2,\ldots,p^\alpha,

the ones not coprime to pαp^\alpha are exactly the multiples of pp. There are

pα1 p^{\alpha-1}

such multiples:

p,2p,3p,,pα1p. p,2p,3p,\ldots,p^{\alpha-1}p.

Hence

φ(pα)=pαpα1. \varphi(p^\alpha)=p^\alpha-p^{\alpha-1}.

Equivalently,

φ(pα)=pα(11p). \varphi(p^\alpha)=p^\alpha\left(1-\frac1p\right).

For example,

φ(8)=φ(23)=2322=4. \varphi(8)=\varphi(2^3)=2^3-2^2=4.

Indeed, the integers

1,3,5,7 1,3,5,7

are coprime to 88.

Multiplicativity

The totient function is multiplicative. If

gcd(m,n)=1, \gcd(m,n)=1,

then

φ(mn)=φ(m)φ(n). \varphi(mn)=\varphi(m)\varphi(n).

This follows from the Chinese remainder theorem. When mm and nn are coprime,

Z/mnZZ/mZ×Z/nZ. \mathbb{Z}/mn\mathbb{Z} \cong \mathbb{Z}/m\mathbb{Z} \times \mathbb{Z}/n\mathbb{Z}.

A residue class modulo mnmn is invertible exactly when its images modulo mm and modulo nn are both invertible. Therefore the number of units modulo mnmn is the product of the number of units modulo mm and modulo nn.

Thus

φ(mn)=φ(m)φ(n). \varphi(mn)=\varphi(m)\varphi(n).

Formula from Prime Factorization

Let

n=p1α1p2α2prαr n=p_1^{\alpha_1}p_2^{\alpha_2}\cdots p_r^{\alpha_r}

be the canonical prime decomposition of nn. Since the prime powers are pairwise coprime, multiplicativity gives

φ(n)=φ(p1α1)φ(p2α2)φ(prαr). \varphi(n) = \varphi(p_1^{\alpha_1}) \varphi(p_2^{\alpha_2}) \cdots \varphi(p_r^{\alpha_r}).

Using the prime-power formula,

φ(piαi)=piαi(11pi), \varphi(p_i^{\alpha_i}) = p_i^{\alpha_i}\left(1-\frac1{p_i}\right),

we obtain

φ(n)=npn(11p). \varphi(n) = n\prod_{p\mid n}\left(1-\frac1p\right).

The product is over the distinct prime divisors of nn.

For example,

12=223. 12=2^2\cdot3.

Thus

φ(12)=12(112)(113)=4. \varphi(12) = 12\left(1-\frac12\right)\left(1-\frac13\right) = 4.

The coprime integers from 11 to 1212 are

1,5,7,11. 1,5,7,11.

Totient and Units

The function φ(n)\varphi(n) has an algebraic meaning:

φ(n)=(Z/nZ)×. \varphi(n)=|(\mathbb{Z}/n\mathbb{Z})^\times|.

That is, φ(n)\varphi(n) is the number of units modulo nn.

For example,

(Z/10Z)×={[1],[3],[7],[9]}, (\mathbb{Z}/10\mathbb{Z})^\times = \{[1],[3],[7],[9]\},

so

φ(10)=4. \varphi(10)=4.

This interpretation connects elementary counting with finite group theory.

Euler’s Theorem

Euler’s theorem states that if

gcd(a,n)=1, \gcd(a,n)=1,

then

aφ(n)1(modn). a^{\varphi(n)}\equiv1\pmod n.

This generalizes Fermat’s little theorem, which is the special case where n=pn=p is prime:

ap11(modp) a^{p-1}\equiv1\pmod p

when

pa. p\nmid a.

Euler’s theorem follows because the units modulo nn form a finite multiplicative group of size φ(n)\varphi(n). Powers of any unit eventually return to the identity in a structured way.

Sum over Divisors

The totient function satisfies the important identity

dnφ(d)=n. \sum_{d\mid n}\varphi(d)=n.

One way to see this is to classify the integers

1,2,,n 1,2,\ldots,n

according to their greatest common divisor with nn.

For each divisor dnd\mid n, the number of integers aa with

1an 1\le a\le n

and

gcd(a,n)=nd \gcd(a,n)=\frac nd

is

φ(d). \varphi(d).

Adding over all divisors dnd\mid n counts each integer from 11 to nn exactly once. Therefore

dnφ(d)=n. \sum_{d\mid n}\varphi(d)=n.

For example, if

n=6, n=6,

then

φ(1)+φ(2)+φ(3)+φ(6)=1+1+2+2=6. \varphi(1)+\varphi(2)+\varphi(3)+\varphi(6) = 1+1+2+2 = 6.

Role in Number Theory

Euler’s totient function measures the invertible part of modular arithmetic. It counts the residue classes that can be divided by, and it controls many exponent laws modulo nn.

It appears in Euler’s theorem, primitive roots, reduced residue systems, RSA cryptography, Dirichlet characters, and multiplicative number theory.

The main idea is that φ(n)\varphi(n) records how much of arithmetic modulo nn remains multiplicatively reversible.