A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Euler's Totient Function

Graduate Depth 79 in the knowledge graph ☐ I know this ☆ Set as goal
32topics build on this
377prerequisites beneath it
See this on the map →
Arithmetic Functions and MultiplicativityModular Arithmetic and Congruences→→Cryptographic Applications: RSAEuler's Theorem+1 more
totient euler-phi coprime

Core Idea

Euler's totient function φ(n) counts the positive integers up to n that are coprime to n. For a prime power pk, φ(pk) = pk-1(p-1). Since φ is multiplicative, φ(n) = n∏(1 - 1/p) over primes dividing n.

How It's Best Learned

Compute φ(n) for small values and verify the formula. Recognize the multiplicative structure and its connection to cyclic groups.

Common Misconceptions

Thinking φ(n) requires checking all n integers (use the formula instead). Confusing φ with other arithmetic functions like σ or τ.

Explainer

The totient function asks: among the integers 1, 2, ..., n, how many share no common factor with n? If n = 12, the integers coprime to 12 are {1, 5, 7, 11} — just those sharing no factor of 2 or 3 — so φ(12) = 4. You already know modular arithmetic, so you know that working "mod n" means working within a set of residues; φ(n) precisely counts the size of the multiplicative group mod n, the residues that have multiplicative inverses. This connection is why the totient function appears everywhere in number theory and cryptography.

The formula φ(n) = n∏(1 − 1/p) over primes p dividing n comes from inclusion-exclusion. Start with n integers; remove the multiples of p₁ (there are n/p₁ of them), then the multiples of p₂, then add back the double-counted multiples of p₁p₂, and so on. Each prime factor p "knocks out" a fraction 1/p of the survivors, leaving a fraction (1 − 1/p). For n = 12 = 2² × 3: φ(12) = 12 × (1 − 1/2) × (1 − 1/3) = 12 × 1/2 × 2/3 = 4. The multiplicativity you studied — that φ(mn) = φ(m)φ(n) whenever gcd(m, n) = 1 — lets you decompose any n into its prime power factors first: φ(pk) = pk−1(p−1), because the only numbers not coprime to pk are its pk−1 multiples.

The power of φ becomes visible in Euler's theorem: if gcd(a, n) = 1, then aφ(n) ≡ 1 (mod n). This is a direct consequence of the multiplicative group having order φ(n) — every element raised to the group's order returns to the identity. Fermat's little theorem is the special case n = p prime, where φ(p) = p − 1. This interplay between counting (φ), modular arithmetic, and group structure is a microcosm of how number theory works: a simple counting question opens into deep algebraic structure.

The RSA cryptosystem rests entirely on φ. Given n = pq (a product of two large primes), φ(n) = (p−1)(q−1) is easy to compute if you know p and q, but essentially impossible if you only know n (factoring large integers is computationally hard). The encryption and decryption exponents are chosen to be inverses mod φ(n), and the security guarantee — that decryption undoes encryption — follows directly from Euler's theorem. The totient function thus bridges elementary arithmetic counting and the algorithms securing modern internet communication.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → Divisibility and Greatest Common Divisor → The Fundamental Theorem of Arithmetic → Divisibility Theory (Formal Treatment) → Fundamental Theorem of Arithmetic (Rigorous Proof) → Arithmetic Functions and Multiplicativity → Euler's Totient Function

Longest path: 80 steps · 377 total prerequisite topics

Prerequisites (2)

Leads To (3)