The Euler Totient Function

How many numbers between 11 and nn share no common factor with nn? This deceptively simple counting question was first studied systematically by Leonhard Euler in the 1760s. It turns out to govern the arithmetic of every cyclic system built from the integers. The answer is captured by a single arithmetic function, Euler's totient φ(n)\varphi(n). The question of how to compute it efficiently forces us to confront something deeper. We must face the interaction between the additive structure of "counting" and the multiplicative structure of "factoring." The totient function matters because it is the prototype of a multiplicative function. This is one whose value on a product of coprime integers factors as the product of the values. This single structural property, once established, converts an intractable counting problem into an easy calculation. That calculation comes straight from the prime factorization of nn. The same pattern recurs throughout number theory. First, define a function combinatorially. Then prove multiplicativity. Then read off a closed formula from prime powers. And φ\varphi is the cleanest possible place to learn it. The big picture is that φ(n)\varphi(n) is not just a counting curiosity. It is exactly the order of the group of units (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^\times. This is the multiplicative group of residues coprime to nn. Every theorem about that group rests on knowing φ(n)\varphi(n) precisely. This includes Euler's generalization of Fermat's Little Theorem, the structure theory of cyclic groups, and ultimately the security proof behind RSA encryption. This article gives the rigorous definition of φ\varphi. It proves from first principles that it is multiplicative, using the Chinese Remainder Theorem. It also derives the classical prime-power product formula. Along the way we build the intuition and work two nontrivial numerical examples. We show exactly why coprimality of the arguments cannot be dropped. Finally, we point toward Mobius Inversion and the RSA Cryptosystem as the natural continuations.

Key takeaways
  • φ(n)\varphi(n) counts integers in {1,…,n}\{1,\dots,n\} coprime to nn; φ(1)=1\varphi(1)=1 by convention.
  • φ\varphi is a multiplicative function: gcd⁡(m,n)=1  ⟹  φ(mn)=φ(m)φ(n)\gcd(m,n)=1 \implies \varphi(mn)=\varphi(m)\varphi(n).
  • The proof uses the Chinese Remainder Theorem to build a bijection between unit residues mod mnmn and pairs of unit residues mod mm, mod nn.
  • On a prime power, φ(pk)=pk−pk−1=pk−1(p−1)\varphi(p^k) = p^k - p^{k-1} = p^{k-1}(p-1), proved by direct sieving of multiples of pp.
  • Combining these via the Fundamental Theorem of Arithmetic gives the product formula φ(n)=n∏p∣n(1−1p)\varphi(n) = n\prod_{p\mid n}\left(1-\tfrac1p\right).
  • Dropping coprimality breaks multiplicativity entirely: φ(4)=2\varphi(4)=2 but φ(2)φ(2)=1≠2\varphi(2)\varphi(2)=1\ne 2.
  • Key idea: counting coprime residues is hard directly but easy after factoring nn, because φ\varphi respects the multiplicative structure of Z\mathbb{Z}.

Where this lives today

The totient function is the load-bearing gear inside the RSA Cryptosystem: given a large n=pqn = pq for secret primes p,qp,q, the private key is computed as the modular inverse of the public exponent modulo φ(n)=(p−1)(q−1)\varphi(n) = (p-1)(q-1), and the entire security argument rests on the fact that computing φ(n)\varphi(n) is exactly as hard as factoring nn. In group theory, φ(n)\varphi(n) is the order of the abelian group (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^\times, feeding directly into the classification of finite abelian groups and into constructions of finite fields and cyclic groups used throughout algebra. In analytic number theory, φ\varphi is a key example in the theory of arithmetic functions, and its behavior is studied via Mobius Inversion, which recovers φ\varphi from the identity ∑d∣nφ(d)=n\sum_{d\mid n}\varphi(d) = n and expresses φ(n)=∑d∣nμ(d)nd\varphi(n) = \sum_{d\mid n}\mu(d)\frac{n}{d} using the Möbius function μ\mu. The average order of φ(n)/n\varphi(n)/n over long ranges connects to the density of squarefree numbers and to results like ∑n≤xφ(n)∼3π2x2\sum_{n\le x}\varphi(n) \sim \frac{3}{\pi^2}x^2, linking φ\varphi to ζ(2)=π2/6\zeta(2) = \pi^2/6. In combinatorics, φ(n)\varphi(n) counts the number of generators of a cyclic group of order nn, the number of primitive nn-th roots of unity, and the number of distinct necklaces or rotational symmetries in various counting problems via Burnside-type arguments.

Ask the tutor: How does Möbius inversion recover the totient formula from the divisor-sum identity ∑d∣nφ(d)=n\sum_{d\mid n}\varphi(d)=n?

DefinitionEuler's totient function

For a positive integer nn, define

φ(n)  =  #{ k∈Z:1≤k≤n, gcd⁡(k,n)=1 }.\varphi(n) \;=\; \#\{\, k \in \mathbb{Z} : 1 \le k \le n,\ \gcd(k,n) = 1 \,\}.

By convention φ(1)=1\varphi(1) = 1 (the single integer k=1k=1 satisfies gcd⁡(1,1)=1\gcd(1,1)=1). Equivalently, φ(n)\varphi(n) is the number of elements in a reduced residue system modulo nn, i.e. the cardinality of the unit group

(Z/nZ)×={ aˉ∈Z/nZ:gcd⁡(a,n)=1 }.(\mathbb{Z}/n\mathbb{Z})^\times = \{\, \bar{a} \in \mathbb{Z}/n\mathbb{Z} : \gcd(a,n)=1 \,\}.

The two descriptions agree because gcd⁡(k,n)=1\gcd(k,n)=1 depends only on the residue class of kk modulo nn: if k≡k′(modn)k \equiv k' \pmod n then gcd⁡(k,n)=gcd⁡(k′,n)\gcd(k,n) = \gcd(k',n) (a consequence of the Euclidean algorithm, since gcd⁡(k,n)=gcd⁡(k−n,n)\gcd(k,n) = \gcd(k-n,n) whenever k−nk-n makes sense, and this identity is preserved under repeated addition/subtraction of nn).

Intuition

Picture the integers from 11 to nn laid out in a row, and imagine crossing out every number that shares a factor with nn. What survives is exactly the set counted by φ(n)\varphi(n). For a prime pp, nothing is crossed out except multiples of pp itself, so φ(p)=p−1\varphi(p) = p - 1: all residues except 00 survive. For n=12=22⋅3n = 12 = 2^2 \cdot 3, we must cross out multiples of 22 (namely 2,4,6,8,10,122,4,6,8,10,12) and multiples of 33 (namely 3,6,9,123,6,9,12), being careful not to double-remove the multiples of 66. What's left is {1,5,7,11}\{1,5,7,11\}, so φ(12)=4\varphi(12) = 4. The key structural insight is that this "sieving" process interacts beautifully with factorization. If n=mn′n = mn' with gcd⁡(m,n′)=1\gcd(m,n')=1, the Chinese Remainder Theorem tells us that living modulo nn is the same information as living modulo mm and modulo n′n' simultaneously — residues mod nn correspond bijectively to pairs (residue mod mm, residue mod n′n'). Being a unit mod nn translates exactly to being a unit in both coordinates, and unit-ness in each coordinate is an independent condition. This independence is the engine behind multiplicativity: it converts a single hard count into a product of two easier counts.

Figure
The reduced residues mod 12, sieved from residues mod 4 and mod 3
Residues 1..12, marked by shared factor with 12 1 2 3 4 5 6 7 8 9 10 11 12 coprime to 12 (survives) shares factor 2 shares factor 3 shares factors 2 and 3 Survivors: {1,5,7,11} so φ(12) = 4 = φ(4)·φ(3) = 2·2

The central theorem

TheoremMultiplicativity and the prime-power product formula

(1) Multiplicativity. If m,nm, n are positive integers with gcd⁡(m,n)=1\gcd(m,n) = 1, then

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

(2) Prime powers. If pp is prime and k≥1k \ge 1 is an integer, then

φ(pk)=pk−pk−1=pk−1(p−1).\varphi(p^k) = p^k - p^{k-1} = p^{k-1}(p-1).

(3) Product formula. If n≥2n \ge 2 has prime factorization n=p1a1p2a2⋯prarn = p_1^{a_1} p_2^{a_2}\cdots p_r^{a_r} (with the pip_i distinct primes, ai≥1a_i \ge 1, guaranteed to exist and be unique by the Fundamental Theorem of Arithmetic), then

φ(n)  =  ∏i=1rpiai−1(pi−1)  =  n∏i=1r(1−1pi).\varphi(n) \;=\; \prod_{i=1}^{r} p_i^{a_i - 1}(p_i - 1) \;=\; n \prod_{i=1}^r \left(1 - \frac{1}{p_i}\right).
Proof

We prove the three parts in order, each building on the previous, and combine them at the end. The technique throughout is a direct bijective/counting argument together with the Chinese Remainder Theorem; nothing here relies on results built on top of multiplicativity, so the proof is not circular.

Part 2 first (prime powers), as it is used to illustrate the base case and is logically independent of Part 1. Fix a prime pp and k≥1k \ge 1. We count integers jj with 1≤j≤pk1 \le j \le p^k that are not coprime to pkp^k. Since the only prime factor of pkp^k is pp itself, gcd⁡(j,pk)>1\gcd(j, p^k) > 1 if and only if p∣jp \mid j. The multiples of pp in the range [1,pk][1, p^k] are exactly

p,2p,3p,…,pk−1⋅p,p, 2p, 3p, \dots, p^{k-1}\cdot p,

and there are precisely pk−1p^{k-1} of them (they are in bijection with {1,2,…,pk−1}\{1, 2, \dots, p^{k-1}\} via j=tpj = tp). Hence the number of integers in [1,pk][1,p^k] coprime to pkp^k is the total count minus these excluded multiples:

φ(pk)=pk−pk−1.\varphi(p^k) = p^k - p^{k-1}.

This proves Part 2.

Part 1 (multiplicativity), via the Chinese Remainder Theorem. Let m,n≥1m,n \ge 1 with gcd⁡(m,n)=1\gcd(m,n) = 1. Recall the Chinese Remainder Theorem (CRT): the map

Φ:Z/mnZ⟶Z/mZ×Z/nZ,Φ(aˉ)=(a  m, a  n)\Phi : \mathbb{Z}/mn\mathbb{Z} \longrightarrow \mathbb{Z}/m\mathbb{Z} \times \mathbb{Z}/n\mathbb{Z}, \qquad \Phi(\bar{a}) = (a \bmod m,\ a \bmod n)

is a well-defined bijection (indeed a ring isomorphism) whenever gcd⁡(m,n)=1\gcd(m,n)=1. Well-definedness is immediate since a≡a′(modmn)a \equiv a' \pmod{mn} implies a≡a′(modm)a \equiv a' \pmod m and a≡a′(modn)a \equiv a' \pmod n. Injectivity: if Φ(aˉ)=Φ(aˉ′)\Phi(\bar a) = \Phi(\bar a') then m∣(a−a′)m \mid (a-a') and n∣(a−a′)n \mid (a - a'); since gcd⁡(m,n)=1\gcd(m,n)=1, mm and nn have no common prime factor, so by unique factorization mn∣(a−a′)mn \mid (a-a'), i.e. aˉ=aˉ′\bar a = \bar a' in Z/mnZ\mathbb{Z}/mn\mathbb{Z}. Surjectivity follows because Φ\Phi is an injective map between finite sets of the same size mn=m⋅nmn = m\cdot n, hence bijective. (Explicitly, surjectivity can also be shown constructively: since gcd⁡(m,n)=1\gcd(m,n)=1 there exist integers u,vu,v with um+vn=1um + vn = 1; given any target (b,c)(b,c), the element a=c⋅um+b⋅vna = c\cdot um + b \cdot vn satisfies a≡b(modm)a \equiv b \pmod m and a≡c(modn)a \equiv c \pmod n, which one checks directly using um≡0(modm)um \equiv 0 \pmod m, vn≡1(modm)vn\equiv 1 \pmod m... more precisely vn=1−um≡1(modm)vn = 1-um \equiv 1\pmod m.) We now claim Φ\Phi restricts to a bijection between the unit group (Z/mnZ)×(\mathbb{Z}/mn\mathbb{Z})^\times and the product of unit groups (Z/mZ)××(Z/nZ)×(\mathbb{Z}/m\mathbb{Z})^\times \times (\mathbb{Z}/n\mathbb{Z})^\times. Key fact: for any integers a,Na, N, gcd⁡(a,N)=1\gcd(a,N) = 1 if and only if aˉ\bar a has a multiplicative inverse modulo NN. (If gcd⁡(a,N)=1\gcd(a,N)=1, Bézout gives xa+yN=1xa + yN = 1 for some integers x,yx,y, so xa≡1(modN)xa \equiv 1 \pmod N, i.e. xx is an inverse. Conversely if xa≡1(modN)xa \equiv 1\pmod N then xa−1=yNxa - 1 = yN for some integer yy, so any common divisor of aa and NN divides xa−yN=1xa - yN = 1, forcing gcd⁡(a,N)=1\gcd(a,N)=1.) Now suppose gcd⁡(a,mn)=1\gcd(a, mn) = 1. Since m∣mnm \mid mn, any common divisor of aa and mm also divides mnmn, hence divides gcd⁡(a,mn)=1\gcd(a,mn)=1; so gcd⁡(a,m)=1\gcd(a,m)=1, and symmetrically gcd⁡(a,n)=1\gcd(a,n)=1. Thus Φ\Phi maps (Z/mnZ)×(\mathbb{Z}/mn\mathbb{Z})^\times into (Z/mZ)××(Z/nZ)×(\mathbb{Z}/m\mathbb{Z})^\times \times (\mathbb{Z}/n\mathbb{Z})^\times. Conversely, suppose gcd⁡(a,m)=1\gcd(a,m)=1 and gcd⁡(a,n)=1\gcd(a,n) = 1. We claim gcd⁡(a,mn)=1\gcd(a,mn)=1. Suppose a prime qq divides both aa and mnmn. By Euclid's Lemma (a consequence of unique factorization), q∣mnq \mid mn implies q∣mq \mid m or q∣nq \mid n. In either case qq divides aa and one of m,nm,n, contradicting gcd⁡(a,m)=1\gcd(a,m)=1 or gcd⁡(a,n)=1\gcd(a,n)=1. So no prime divides both aa and mnmn, i.e. gcd⁡(a,mn)=1\gcd(a,mn)=1. Thus Φ\Phi maps (Z/mnZ)×(\mathbb{Z}/mn\mathbb{Z})^\times onto (Z/mZ)××(Z/nZ)×(\mathbb{Z}/m\mathbb{Z})^\times \times (\mathbb{Z}/n\mathbb{Z})^\times, and combined with the previous paragraph and the fact that Φ\Phi is already a bijection on the full rings, Φ\Phi restricts to a bijection

(Z/mnZ)×  → ∼   (Z/mZ)××(Z/nZ)×.(\mathbb{Z}/mn\mathbb{Z})^\times \;\xrightarrow{\ \sim\ }\; (\mathbb{Z}/m\mathbb{Z})^\times \times (\mathbb{Z}/n\mathbb{Z})^\times.

Taking cardinalities of both sides (finite sets in bijection have equal size) gives

φ(mn)=∣(Z/mnZ)×∣=∣(Z/mZ)×∣⋅∣(Z/nZ)×∣=φ(m)φ(n).\varphi(mn) = \left|(\mathbb{Z}/mn\mathbb{Z})^\times\right| = \left|(\mathbb{Z}/m\mathbb{Z})^\times\right| \cdot \left|(\mathbb{Z}/n\mathbb{Z})^\times\right| = \varphi(m)\varphi(n).

This proves Part 1.

Part 3 (the product formula), combining Parts 1 and 2. Let n=p1a1⋯prarn = p_1^{a_1}\cdots p_r^{a_r} be the prime factorization of nn, which exists and is unique by the Fundamental Theorem of Arithmetic. We induct on rr, the number of distinct prime factors. Base case r=1r=1: n=p1a1n = p_1^{a_1} is a prime power, and Part 2 gives φ(n)=p1a1−1(p1−1)\varphi(n) = p_1^{a_1-1}(p_1-1), matching the claimed formula. Inductive step: suppose the formula holds for any integer with fewer than rr distinct prime factors, and let n=p1a1⋯prarn = p_1^{a_1}\cdots p_r^{a_r} with r≥2r \ge 2. Write n=m⋅prarn = m \cdot p_r^{a_r} where m=p1a1⋯pr−1ar−1m = p_1^{a_1}\cdots p_{r-1}^{a_{r-1}}. Since mm's only prime factors are p1,…,pr−1p_1,\dots,p_{r-1}, all different from prp_r, we have gcd⁡(m,prar)=1\gcd(m, p_r^{a_r}) = 1 (no common prime factor, by unique factorization). By Part 1,

φ(n)=φ(m) φ(prar).\varphi(n) = \varphi(m)\,\varphi(p_r^{a_r}).

By the inductive hypothesis applied to mm (which has r−1r-1 distinct prime factors),

φ(m)=∏i=1r−1piai−1(pi−1),\varphi(m) = \prod_{i=1}^{r-1} p_i^{a_i-1}(p_i - 1),

and by Part 2, φ(prar)=prar−1(pr−1)\varphi(p_r^{a_r}) = p_r^{a_r - 1}(p_r - 1). Multiplying these gives

φ(n)=∏i=1rpiai−1(pi−1),\varphi(n) = \prod_{i=1}^{r} p_i^{a_i - 1}(p_i - 1),

completing the induction. Finally, rewrite each factor: piai−1(pi−1)=piai(1−1pi)p_i^{a_i - 1}(p_i - 1) = p_i^{a_i}\left(1 - \frac1{p_i}\right). Multiplying over i=1,…,ri=1,\dots,r and using ∏ipiai=n\prod_i p_i^{a_i} = n gives

φ(n)=(∏i=1rpiai)∏i=1r(1−1pi)=n∏i=1r(1−1pi).\varphi(n) = \left(\prod_{i=1}^r p_i^{a_i}\right)\prod_{i=1}^r\left(1-\frac1{p_i}\right) = n\prod_{i=1}^r\left(1-\frac1{p_i}\right).

This is exactly the stated product formula, completing the proof of the theorem. ■\blacksquare

∎

Worked examples

Example 1: n=2 450n = 2\,450. Factor nn: 2450=2⋅1225=2⋅52⋅245=2⋅52⋅5⋅492450 = 2 \cdot 1225 = 2 \cdot 5^2 \cdot 245 = 2 \cdot 5^2 \cdot 5 \cdot 49. Let's be careful and redo this cleanly.

2450=2⋅1225,1225=52⋅49=52⋅72.2450 = 2 \cdot 1225, \qquad 1225 = 5^2 \cdot 49 = 5^2 \cdot 7^2.

So 2450=21⋅52⋅722450 = 2^1 \cdot 5^2 \cdot 7^2. Check: 2⋅25⋅49=2⋅1225=24502 \cdot 25 \cdot 49 = 2\cdot 1225 = 2450. Correct. By the product formula,

φ(2450)=2450(1−12)(1−15)(1−17)=2450⋅12⋅45⋅67.\varphi(2450) = 2450 \left(1 - \frac12\right)\left(1-\frac15\right)\left(1-\frac17\right) = 2450 \cdot \frac12 \cdot \frac45 \cdot \frac67.

Compute stepwise: 2450⋅12=12252450 \cdot \tfrac12 = 1225. Then 1225⋅45=9801225 \cdot \tfrac45 = 980. Then 980⋅67=840980 \cdot \tfrac67 = 840. So φ(2450)=840\varphi(2450) = 840. Cross-check via the prime-power factors directly: φ(2)=1\varphi(2) = 1, φ(52)=51(5−1)=20\varphi(5^2) = 5^1(5-1) = 20, φ(72)=71(7−1)=42\varphi(7^2) = 7^1(7-1) = 42. By multiplicativity (applicable since 2,25,492, 25, 49 are pairwise coprime),

φ(2450)=φ(2)⋅φ(25)⋅φ(49)=1⋅20⋅42=840.\varphi(2450) = \varphi(2)\cdot\varphi(25)\cdot\varphi(49) = 1 \cdot 20 \cdot 42 = 840.

Both routes agree: φ(2450)=840\varphi(2450) = 840.

Example 2: verifying multiplicativity on a genuinely asymmetric coprime pair, m=63m = 63, n=100n = 100. Here gcd⁡(63,100)=1\gcd(63,100)=1 since 63=32⋅763 = 3^2\cdot 7 and 100=22⋅52100 = 2^2\cdot 5^2 share no prime factor. We compute φ(63)\varphi(63), φ(100)\varphi(100), and φ(6300)\varphi(6300) independently and check the multiplicativity identity numerically, which is a genuine test of the theorem (not a restatement of it). φ(63)=φ(32)⋅φ(7)=3(3−1)⋅6=6⋅6=36\varphi(63) = \varphi(3^2)\cdot \varphi(7) = 3(3-1)\cdot 6 = 6\cdot 6 = 36. φ(100)=φ(22)⋅φ(52)=2(2−1)⋅5(5−1)=2⋅20=40\varphi(100) = \varphi(2^2)\cdot\varphi(5^2) = 2(2-1)\cdot 5(5-1) = 2\cdot 20 = 40. Now compute φ(6300)\varphi(6300) directly from its own factorization. Since 6300=63×100=32⋅7⋅22⋅526300 = 63 \times 100 = 3^2\cdot 7\cdot 2^2\cdot 5^2, the product formula gives

φ(6300)=6300(1−12)(1−13)(1−15)(1−17).\varphi(6300) = 6300\left(1-\frac12\right)\left(1-\frac13\right)\left(1-\frac15\right)\left(1-\frac17\right).

Compute stepwise: 6300⋅12=31506300\cdot\tfrac12 = 3150; 3150⋅23=21003150 \cdot \tfrac23 = 2100; 2100⋅45=16802100\cdot\tfrac45 = 1680; 1680⋅67=14401680\cdot\tfrac67 = 1440. So φ(6300)=1440\varphi(6300) = 1440. And indeed φ(63)⋅φ(100)=36×40=1440\varphi(63)\cdot\varphi(100) = 36 \times 40 = 1440. The two independent computations match exactly, confirming multiplicativity in this nontrivial, non-symmetric case where m≠nm\ne n and neither is a prime power alone.

CounterexampleMultiplicativity fails without coprimality

The hypothesis gcd⁡(m,n)=1\gcd(m,n)=1 in Part 1 of the theorem is essential, not a technical nicety. Take m=n=2m = n = 2, so mn=4mn = 4 and gcd⁡(m,n)=gcd⁡(2,2)=2≠1\gcd(m,n) = \gcd(2,2) = 2 \ne 1. Directly: φ(2)=1\varphi(2) = 1 (only k=1k=1 in {1,2}\{1,2\} is coprime to 22), so φ(m)φ(n)=φ(2)φ(2)=1⋅1=1\varphi(m)\varphi(n) = \varphi(2)\varphi(2) = 1\cdot 1 = 1. But by Part 2 of the theorem (which needs no coprimality hypothesis, since it concerns a single prime power), φ(4)=φ(22)=21(2−1)=2\varphi(4) = \varphi(2^2) = 2^1(2-1) = 2. So φ(mn)=φ(4)=2≠1=φ(m)φ(n)\varphi(mn) = \varphi(4) = 2 \ne 1 = \varphi(m)\varphi(n): the multiplicativity identity fails once m,nm,n share the factor 22. The reason traces directly back to the proof: the Chinese Remainder Theorem map Φ:Z/4Z→Z/2Z×Z/2Z\Phi:\mathbb{Z}/4\mathbb{Z} \to \mathbb{Z}/2\mathbb{Z}\times\mathbb{Z}/2\mathbb{Z} is not a bijection when gcd⁡(2,2)=2≠1\gcd(2,2)=2\ne1 (the source has 44 elements, the target has only 44 elements too by coincidence of size, but Φ\Phi is not injective: Φ(0)=(0,0)\Phi(0) = (0,0) and Φ(2)=(0,0)\Phi(2) = (0,0) collide). Injectivity used gcd⁡(m,n)=1\gcd(m,n)=1 essentially, via unique factorization applied to conclude mn∣(a−a′)mn \mid (a-a') from m∣(a−a′)m\mid(a-a') and n∣(a−a′)n\mid (a-a') — and this step is simply false when m,nm,n share a common factor. Without that bijection, the cardinality argument collapses, and indeed the conclusion is false.

Scope, edge cases & common traps

SituationWhat holdsWhat to watch for
gcd⁡(m,n)=1\gcd(m,n)=1φ(mn)=φ(m)φ(n)\varphi(mn)=\varphi(m)\varphi(n)Fails badly if gcd⁡(m,n)>1\gcd(m,n)>1; see counterexample
n=pkn = p^k, pp primeφ(pk)=pk−1(p−1)\varphi(p^k) = p^{k-1}(p-1)Requires k≥1k\ge 1; φ(p0)=φ(1)=1\varphi(p^0)=\varphi(1)=1 trivially, not from this formula
n=1n=1φ(1)=1\varphi(1) = 1 by conventionEmpty-product edge case in the product formula: n=1n=1 has no prime factors, and the empty product is 11, consistent
General n≥2n\ge2φ(n)=n∏p∣n(1−1/p)\varphi(n) = n\prod_{p\mid n}(1-1/p)The product is over distinct primes dividing nn, not over prime-power factors — a common bookkeeping slip
φ\varphi is not completely multiplicativeφ(p2)≠φ(p)φ(p)\varphi(p^2)\ne \varphi(p)\varphi(p) in generale.g. φ(4)=2\varphi(4)=2 but φ(2)2=1\varphi(2)^2=1; multiplicative ≠\ne completely multiplicative

The mathematician behind it

Origins · 1 minLeonhard Euler and how this was discovered
LE
Leonhard Euler
1707–1783 · 18th-century Basel/Berlin/St. Petersburg

Leonhard Euler was among the most prolific mathematicians in history, contributing foundational results across analysis, mechanics, graph theory, and number theory. He introduced the totient function (originally denoted π(n)\pi(n) or later φ(n)\varphi(n), called the "Euler phi function" today) in the course of generalizing Fermat's Little Theorem to composite moduli, a result now known as Euler's theorem: aφ(n)≡1(modn)a^{\varphi(n)}\equiv 1 \pmod n whenever gcd⁡(a,n)=1\gcd(a,n)=1. His interest in the function grew from a purely combinatorial question about counting fractions with denominator nn in lowest terms, but he quickly recognized its multiplicative structure as a computational shortcut — precisely the theorem proved above.

History
- 1736: Euler proves the special case of his theorem for prime modulus, matching Fermat's earlier (unpublished) claim.
- 1760: Euler introduces the totient function while working on generalizing Fermat's Little Theorem to arbitrary moduli.
- 1763: Euler publishes the general theorem aφ(n)≡1(modn)a^{\varphi(n)}\equiv 1\pmod n for gcd⁡(a,n)=1\gcd(a,n)=1, establishing the totient's central role.
- 1801: Carl Friedrich Gauss, in Disquisitiones Arithmeticae, introduces the modern notation φ(n)\varphi(n) and systematizes its properties within congruence theory.
- 1970s: The totient function becomes a cornerstone of public-key cryptography with the invention of RSA, which relies on φ(n)\varphi(n) for key generation when nn is a product of two large primes.
Is Euler's totient function ever equal to an odd number greater than 1?

No. For n≥3n \ge 3, φ(n)\varphi(n) is always even. If nn has an odd prime factor pp, the factor (p−1)(p-1) appearing in the product formula is even, making the whole product even. If nn is a power of 22 greater than 22, say n=2kn = 2^k with k≥2k\ge2, then φ(n)=2k−1(2−1)=2k−1\varphi(n) = 2^{k-1}(2-1) = 2^{k-1}, which is even since k−1≥1k-1\ge1. The only values with φ(n)\varphi(n) odd are n=1n=1 (where φ(1)=1\varphi(1)=1) and n=2n=2 (where φ(2)=1\varphi(2)=1); every other input yields an even output, a fact often used to rule out candidate totient values quickly.

Does φ(n)=φ(n+1)\varphi(n) = \varphi(n+1) ever happen, or is the function strictly increasing?

The totient function is not monotonic and such coincidences do occur; for example φ(1)=φ(2)=1\varphi(1)=\varphi(2)=1, and later φ(5)=4=φ(8)\varphi(5)=4=\varphi(8). There is no theorem forcing φ(n)<φ(n+1)\varphi(n) < \varphi(n+1) in general, because φ(n)\varphi(n) depends on the number and size of prime factors of nn, which fluctuates irregularly. What is true, and provable from the product formula, is that φ(n)→∞\varphi(n) \to \infty as n→∞n\to\infty, so equal values can only recur among small or specially structured nn; asymptotically φ(n)\varphi(n) grows without bound, though with large gaps of near-constant behavior for numbers with many small prime factors.

How is φ(n)\varphi(n) related to the number of generators of a cyclic group of order nn?

If GG is cyclic of order nn, generated by gg, then gkg^k generates GG if and only if gcd⁡(k,n)=1\gcd(k,n)=1. This is because the order of gkg^k in a cyclic group of order nn equals n/gcd⁡(k,n)n/\gcd(k,n), and this order equals nn (i.e., gkg^k generates the whole group) precisely when gcd⁡(k,n)=1\gcd(k,n)=1. Since kk ranges over {1,…,n}\{1,\dots,n\} to enumerate all elements gkg^k, the count of generators is exactly φ(n)\varphi(n) by definition. This is the reason φ(n)\varphi(n) also counts primitive nn-th roots of unity in C\mathbb{C}, since these form a cyclic group of order nn under multiplication.

Why is φ\varphi called "multiplicative" rather than "completely multiplicative"?

A function ff is multiplicative if f(mn)=f(m)f(n)f(mn)=f(m)f(n) only when gcd⁡(m,n)=1\gcd(m,n)=1, while completely multiplicative means this holds for all m,nm,n with no coprimality restriction. The totient function satisfies the weaker property only: as the counterexample shows, φ(4)=2≠φ(2)φ(2)=1\varphi(4) = 2 \ne \varphi(2)\varphi(2) = 1, so φ\varphi fails to be completely multiplicative. This distinction matters throughout analytic number theory because many important functions (like φ\varphi, the divisor function d(n)d(n), and the Möbius function μ\mu) are multiplicative but not completely multiplicative, while others (like nsn^s for the Dirichlet series variable ss) are completely multiplicative, and the two classes behave differently under Dirichlet convolution.

Can φ(n)\varphi(n) be computed without factoring nn?

No efficient general method is known, and this is precisely why φ(n)\varphi(n) underlies RSA security. The product formula shows that knowing φ(n)\varphi(n) is computationally equivalent to knowing the prime factorization of nn: given the factorization, φ(n)\varphi(n) is easy to compute via the formula proved above, and conversely, if n=pqn=pq for two unknown primes, knowing both nn and φ(n)\varphi(n) lets you recover pp and qq by solving the quadratic x2−(n−φ(n)+1)x+n=0x^2 - (n-\varphi(n)+1)x + n = 0, whose roots are pp and qq. Since factoring large semiprimes is believed to be computationally hard, computing φ(n)\varphi(n) for such nn is believed equally hard, absent the factorization.

What is the relationship between φ(n)\varphi(n) and the sum ∑d∣nφ(d)\sum_{d \mid n} \varphi(d)?

There is a beautiful identity, ∑d∣nφ(d)=n\sum_{d\mid n}\varphi(d) = n, sometimes called Gauss's theorem on the totient function. It follows from partitioning {1,…,n}\{1,\dots,n\} by the value of gcd⁡(k,n)\gcd(k,n): for each divisor dd of nn, exactly φ(n/d)\varphi(n/d) integers kk in that range satisfy gcd⁡(k,n)=d\gcd(k,n)=d. Summing φ(n/d)\varphi(n/d) over all divisors dd of nn (equivalently, summing φ(d)\varphi(d) over all divisors dd, by re-indexing) recovers all nn integers exactly once, giving the identity. This identity is the launching point for deriving φ\varphi via Mobius Inversion, expressing φ(n)=∑d∣nμ(d)(n/d)\varphi(n) = \sum_{d\mid n}\mu(d)(n/d).

Is the product formula the fastest way to compute φ(n)\varphi(n) by hand for large nn?

Yes, given the factorization of nn, the product formula is essentially optimal: it requires one term per distinct prime factor, versus checking gcd⁡(k,n)=1\gcd(k,n)=1 for every kk from 11 to nn directly from the definition, which takes nn steps. The bottleneck is factoring nn itself, not evaluating the formula afterward — for a number with rr distinct prime factors, the formula needs only O(r)O(r) arithmetic operations once factorization is known, which is exponentially faster than the brute-force gcd-counting definition for large nn.

Before this

Where this leads