The Euler Totient Function
How many numbers between and share no common factor with ? 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 . 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 . 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 is the cleanest possible place to learn it. The big picture is that is not just a counting curiosity. It is exactly the order of the group of units . This is the multiplicative group of residues coprime to . Every theorem about that group rests on knowing 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 . 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.
- counts integers in coprime to ; by convention.
- is a multiplicative function: .
- The proof uses the Chinese Remainder Theorem to build a bijection between unit residues mod and pairs of unit residues mod , mod .
- On a prime power, , proved by direct sieving of multiples of .
- Combining these via the Fundamental Theorem of Arithmetic gives the product formula .
- Dropping coprimality breaks multiplicativity entirely: but .
- Key idea: counting coprime residues is hard directly but easy after factoring , because respects the multiplicative structure of .
Where this lives today
The totient function is the load-bearing gear inside the RSA Cryptosystem: given a large for secret primes , the private key is computed as the modular inverse of the public exponent modulo , and the entire security argument rests on the fact that computing is exactly as hard as factoring . In group theory, is the order of the abelian group , 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, is a key example in the theory of arithmetic functions, and its behavior is studied via Mobius Inversion, which recovers from the identity and expresses using the Möbius function . The average order of over long ranges connects to the density of squarefree numbers and to results like , linking to . In combinatorics, counts the number of generators of a cyclic group of order , the number of primitive -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 ?
For a positive integer , define
By convention (the single integer satisfies ). Equivalently, is the number of elements in a reduced residue system modulo , i.e. the cardinality of the unit group
The two descriptions agree because depends only on the residue class of modulo : if then (a consequence of the Euclidean algorithm, since whenever makes sense, and this identity is preserved under repeated addition/subtraction of ).
Intuition
Picture the integers from to laid out in a row, and imagine crossing out every number that shares a factor with . What survives is exactly the set counted by . For a prime , nothing is crossed out except multiples of itself, so : all residues except survive. For , we must cross out multiples of (namely ) and multiples of (namely ), being careful not to double-remove the multiples of . What's left is , so . The key structural insight is that this "sieving" process interacts beautifully with factorization. If with , the Chinese Remainder Theorem tells us that living modulo is the same information as living modulo and modulo simultaneously — residues mod correspond bijectively to pairs (residue mod , residue mod ). Being a unit mod 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.
The central theorem
(1) Multiplicativity. If are positive integers with , then
(2) Prime powers. If is prime and is an integer, then
(3) Product formula. If has prime factorization (with the distinct primes, , guaranteed to exist and be unique by the Fundamental Theorem of Arithmetic), then
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 and . We count integers with that are not coprime to . Since the only prime factor of is itself, if and only if . The multiples of in the range are exactly
and there are precisely of them (they are in bijection with via ). Hence the number of integers in coprime to is the total count minus these excluded multiples:
This proves Part 2.
Part 1 (multiplicativity), via the Chinese Remainder Theorem. Let with . Recall the Chinese Remainder Theorem (CRT): the map
is a well-defined bijection (indeed a ring isomorphism) whenever . Well-definedness is immediate since implies and . Injectivity: if then and ; since , and have no common prime factor, so by unique factorization , i.e. in . Surjectivity follows because is an injective map between finite sets of the same size , hence bijective. (Explicitly, surjectivity can also be shown constructively: since there exist integers with ; given any target , the element satisfies and , which one checks directly using , ... more precisely .) We now claim restricts to a bijection between the unit group and the product of unit groups . Key fact: for any integers , if and only if has a multiplicative inverse modulo . (If , Bézout gives for some integers , so , i.e. is an inverse. Conversely if then for some integer , so any common divisor of and divides , forcing .) Now suppose . Since , any common divisor of and also divides , hence divides ; so , and symmetrically . Thus maps into . Conversely, suppose and . We claim . Suppose a prime divides both and . By Euclid's Lemma (a consequence of unique factorization), implies or . In either case divides and one of , contradicting or . So no prime divides both and , i.e. . Thus maps onto , and combined with the previous paragraph and the fact that is already a bijection on the full rings, restricts to a bijection
Taking cardinalities of both sides (finite sets in bijection have equal size) gives
This proves Part 1.
Part 3 (the product formula), combining Parts 1 and 2. Let be the prime factorization of , which exists and is unique by the Fundamental Theorem of Arithmetic. We induct on , the number of distinct prime factors. Base case : is a prime power, and Part 2 gives , matching the claimed formula. Inductive step: suppose the formula holds for any integer with fewer than distinct prime factors, and let with . Write where . Since 's only prime factors are , all different from , we have (no common prime factor, by unique factorization). By Part 1,
By the inductive hypothesis applied to (which has distinct prime factors),
and by Part 2, . Multiplying these gives
completing the induction. Finally, rewrite each factor: . Multiplying over and using gives
This is exactly the stated product formula, completing the proof of the theorem.
∎Worked examples
Example 1: . Factor : . Let's be careful and redo this cleanly.
So . Check: . Correct. By the product formula,
Compute stepwise: . Then . Then . So . Cross-check via the prime-power factors directly: , , . By multiplicativity (applicable since are pairwise coprime),
Both routes agree: .
Example 2: verifying multiplicativity on a genuinely asymmetric coprime pair, , . Here since and share no prime factor. We compute , , and independently and check the multiplicativity identity numerically, which is a genuine test of the theorem (not a restatement of it). . . Now compute directly from its own factorization. Since , the product formula gives
Compute stepwise: ; ; ; . So . And indeed . The two independent computations match exactly, confirming multiplicativity in this nontrivial, non-symmetric case where and neither is a prime power alone.
The hypothesis in Part 1 of the theorem is essential, not a technical nicety. Take , so and . Directly: (only in is coprime to ), so . But by Part 2 of the theorem (which needs no coprimality hypothesis, since it concerns a single prime power), . So : the multiplicativity identity fails once share the factor . The reason traces directly back to the proof: the Chinese Remainder Theorem map is not a bijection when (the source has elements, the target has only elements too by coincidence of size, but is not injective: and collide). Injectivity used essentially, via unique factorization applied to conclude from and — and this step is simply false when share a common factor. Without that bijection, the cardinality argument collapses, and indeed the conclusion is false.
Scope, edge cases & common traps
| Situation | What holds | What to watch for |
|---|---|---|
| Fails badly if ; see counterexample | ||
| , prime | Requires ; trivially, not from this formula | |
| by convention | Empty-product edge case in the product formula: has no prime factors, and the empty product is , consistent | |
| General | The product is over distinct primes dividing , not over prime-power factors — a common bookkeeping slip | |
| is not completely multiplicative | in general | e.g. but ; multiplicative completely multiplicative |
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. He introduced the totient function (originally denoted or later , 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: whenever . His interest in the function grew from a purely combinatorial question about counting fractions with denominator in lowest terms, but he quickly recognized its multiplicative structure as a computational shortcut — precisely the theorem proved above.
Is Euler's totient function ever equal to an odd number greater than 1?
No. For , is always even. If has an odd prime factor , the factor appearing in the product formula is even, making the whole product even. If is a power of greater than , say with , then , which is even since . The only values with odd are (where ) and (where ); every other input yields an even output, a fact often used to rule out candidate totient values quickly.
Does ever happen, or is the function strictly increasing?
The totient function is not monotonic and such coincidences do occur; for example , and later . There is no theorem forcing in general, because depends on the number and size of prime factors of , which fluctuates irregularly. What is true, and provable from the product formula, is that as , so equal values can only recur among small or specially structured ; asymptotically grows without bound, though with large gaps of near-constant behavior for numbers with many small prime factors.
How is related to the number of generators of a cyclic group of order ?
If is cyclic of order , generated by , then generates if and only if . This is because the order of in a cyclic group of order equals , and this order equals (i.e., generates the whole group) precisely when . Since ranges over to enumerate all elements , the count of generators is exactly by definition. This is the reason also counts primitive -th roots of unity in , since these form a cyclic group of order under multiplication.
Why is called "multiplicative" rather than "completely multiplicative"?
A function is multiplicative if only when , while completely multiplicative means this holds for all with no coprimality restriction. The totient function satisfies the weaker property only: as the counterexample shows, , so fails to be completely multiplicative. This distinction matters throughout analytic number theory because many important functions (like , the divisor function , and the Möbius function ) are multiplicative but not completely multiplicative, while others (like for the Dirichlet series variable ) are completely multiplicative, and the two classes behave differently under Dirichlet convolution.
Can be computed without factoring ?
No efficient general method is known, and this is precisely why underlies RSA security. The product formula shows that knowing is computationally equivalent to knowing the prime factorization of : given the factorization, is easy to compute via the formula proved above, and conversely, if for two unknown primes, knowing both and lets you recover and by solving the quadratic , whose roots are and . Since factoring large semiprimes is believed to be computationally hard, computing for such is believed equally hard, absent the factorization.
What is the relationship between and the sum ?
There is a beautiful identity, , sometimes called Gauss's theorem on the totient function. It follows from partitioning by the value of : for each divisor of , exactly integers in that range satisfy . Summing over all divisors of (equivalently, summing over all divisors , by re-indexing) recovers all integers exactly once, giving the identity. This identity is the launching point for deriving via Mobius Inversion, expressing .
Is the product formula the fastest way to compute by hand for large ?
Yes, given the factorization of , the product formula is essentially optimal: it requires one term per distinct prime factor, versus checking for every from to directly from the definition, which takes steps. The bottleneck is factoring itself, not evaluating the formula afterward — for a number with distinct prime factors, the formula needs only arithmetic operations once factorization is known, which is exponentially faster than the brute-force gcd-counting definition for large .