elementary number theory
Euler's Totient Function
You should know: prime numbers, modular arithmetic
Overview
Euler's totient function φ(n) counts how many integers from 1 to n are coprime to n (share no common factor with it beyond 1). For a prime p every one of 1, …, p − 1 qualifies, so φ(p) = p − 1; for composite n fewer do, e.g. φ(12) = 4 (only 1, 5, 7, 11). The function is multiplicative — φ(mn) = φ(m)φ(n) when gcd(m, n) = 1 — which together with φ(pᵏ) = pᵏ − pᵏ⁻¹ lets you compute it straight from a prime factorization. Its importance comes from Euler's theorem, a^φ(n) ≡ 1 (mod n) for gcd(a, n) = 1, which generalizes Fermat's little theorem to any modulus and is the exact fact that makes RSA encryption invertible.
Intuition
φ(n) measures how many residues mod n are 'units' — invertible under multiplication. Those units form a group of size φ(n), and in any finite group raising an element to the group's size returns the identity. That single group-theory fact is Euler's theorem, a^φ(n) ≡ 1, which is why the totient count (not n itself) is the right exponent for modular arithmetic.
Formal Definition
For a positive integer n with prime factorization n = ∏ pᵢ^{kᵢ}:
Worked Examples
Use φ(p^k) = p^k − p^{k−1} on each prime power and multiply (the factors are coprime).
Multiply by multiplicativity.
Answer: φ(12) = 4 (the coprime residues are 1, 5, 7, 11).
Practice Problems
Compute 81 mod 10.
What is φ(p) for a prime p, and why?
In RSA with n = pq (p, q distinct primes), what is φ(n), and why does the scheme rely on it staying secret?
Quiz
Summary
- φ(n) counts integers in 1..n coprime to n; φ(p) = p − 1 and φ(pᵏ) = pᵏ − pᵏ⁻¹.
- φ is multiplicative: φ(mn) = φ(m)φ(n) when gcd(m, n) = 1, so φ follows from the factorization.
- Euler's theorem a^φ(n) ≡ 1 (mod n) generalizes Fermat's little theorem and underpins RSA.
Mathematics