On this page
Euler's theorem tells you that a^φ(n) ≡ 1 (mod n) whenever a is coprime to n. It does not promise that φ(n) is the smallest exponent that works for every such a at once. Often it is not, and the exponent that is has its own name.
What is the Carmichael function λ(n)?
The Carmichael function λ(n) is the smallest positive integer m such that a^m ≡ 1 (mod n) for every integer a coprime to n (Wikipedia: Carmichael function). The American mathematician Robert Carmichael defined it in his "Note on a new number theory function" in the Bulletin of the American Mathematical Society, volume 16 (OEIS A002322). OEIS also calls it the reduced totient function, or the universal exponent of n.
Take n = 8. The numbers coprime to 8 are 1, 3, 5 and 7, so φ(8) = 4. Now square them: 9, 25 and 49 each leave remainder 1 when divided by 8. Every unit is back at 1 after two steps, so λ(8) = 2, not 4.
How do you calculate λ(n) from prime powers?
The rule comes in three parts (MathWorld: Carmichael Function):
For an odd prime power, λ(p^k) = φ(p^k) = p^(k−1)(p − 1).
For powers of 2, λ(2) = 1 and λ(4) = 2, but λ(2^k) = 2^(k−2) when k ≥ 3, which is half of φ(2^k).
For any other n, split it into prime powers and take the least common multiple of their λ values.
Step 3 is where λ pulls away from φ. Euler's φ multiplies the pieces; λ takes their lcm. For n = 15 = 3 × 5, φ(15) = 2 × 4 = 8, but λ(15) = lcm(2, 4) = 4. Check with a = 2: 2^4 = 16 ≡ 1 (mod 15).
Since the order of an element of a finite group divides the order of the group, λ(n) always divides φ(n) (Wikipedia: Carmichael function). That is the same idea as Lagrange's theorem on group order and cosets, applied to the units mod n.
Worked table: λ(n) and φ(n) for n = 1 to 20
The λ values below match OEIS A002322; the φ values come from counting the numbers coprime to n.
n = 1 to 7: λ = 1, 1, 2, 2, 4, 2, 6, the same as φ.
n = 8: φ = 4, λ = 2 (the 2^k rule with k = 3).
n = 9, 10, 11: λ = 6, 4, 10, the same as φ.
n = 12 = 4 × 3: φ = 4, λ = lcm(2, 2) = 2.
n = 13, 14: λ = 12, 6, the same as φ.
n = 15 = 3 × 5: φ = 8, λ = lcm(2, 4) = 4.
n = 16: φ = 8, λ = 2^2 = 4.
n = 17, 18, 19: λ = 16, 6, 18, the same as φ.
n = 20 = 4 × 5: φ = 8, λ = lcm(2, 4) = 4.
At the five values where λ is smaller (8, 12, 15, 16 and 20) there can be no primitive root. A primitive root would need order φ(n), but every element's order divides λ(n) (MathWorld). Our post on primitive roots modulo a prime shows the case where they do exist.
What is Korselt's criterion for Carmichael numbers?
A Carmichael number is a composite k with a^(k−1) ≡ 1 (mod k) for every a coprime to k; the first three are 561, 1105 and 1729 (OEIS A002997). The same page gives Korselt's 1899 criterion: a composite odd k is a Carmichael number if and only if k is squarefree and p − 1 divides k − 1 for every prime p dividing k.
In λ language, the two conditions together say exactly that λ(k) divides k − 1. If p² divided k, then p would divide λ(k) but not k − 1. For squarefree k, λ(k) is just the lcm of the p − 1.
Check 561 = 3 × 11 × 17. λ(561) = lcm(2, 10, 16) = 80, and 560 = 7 × 80, so 561 passes. Meanwhile φ(561) = 2 × 10 × 16 = 320, which does not divide 560. Fermat's test sees λ, not φ. Our explainer on Carmichael numbers and the 561 trap in Fermat's test shows what this does to primality testing.
Where does λ(n) appear in RSA?
The RSA standard PKCS #1 v2.2, published as RFC 8017, defines λ(n) as the lcm of r − 1 over the primes r of the modulus. It requires the public exponent e to satisfy gcd(e, λ(n)) = 1, and the private exponent d to be a positive integer less than n with e × d ≡ 1 (mod λ(n)).
A toy key shows why. Take p = 5, q = 11, n = 55. Then φ(55) = 40 but λ(55) = lcm(4, 10) = 20. With e = 3, working mod λ gives d = 7, since 3 × 7 = 21 ≡ 1 (mod 20); working mod φ would give d = 27. Encrypt m = 2: 2^3 = 8. Decrypt with d = 7: 8^2 ≡ 9, 8^4 ≡ 26, 8^6 ≡ 14, and 8^7 ≡ 112 ≡ 2 (mod 55). The message comes back with the smaller exponent. Real keys use far larger primes; this only shows the arithmetic.
A three-step drill for any λ(n)
Factor n into prime powers, and keep the power of 2 separate.
Write λ of each piece: p^(k−1)(p − 1) for odd p; 1, 2 or 2^(k−2) for 2^k.
Take the lcm, then test one a coprime to n to catch slips.
Try it on 24, 35 and 100 (answers: 2, 12, 20). If a step goes wrong, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning, and the Fermi Concept Library gives each concept in mathematics its own lesson when you want the background first.



