Carmichael Function Calculator
Find the smallest exponent that returns every coprime residue to one modulo n, with totient for comparison.
What it does
Euler's theorem says that raising any number coprime to n to the power phi(n) returns one modulo n. The Carmichael function asks a sharper question: what is the smallest exponent that works for every such number at once? That exponent is written lambda(n), and it always divides phi(n).
The function is named after Robert Carmichael, an American mathematician who studied it in the early twentieth century. It is also called the reduced totient function, because it reduces the exponent Euler's theorem gives down to the smallest universal value.
The computation uses the prime power factorization. For an odd prime power the contribution equals its totient. For a power of two at least eight, the contribution is half its totient, because the group of units modulo such a power is not cyclic. The combined value is the least common multiple of the contributions.
This page factors the modulus, computes each prime power contribution, takes their least common multiple and reports the result next to Euler's totient. The difference between the two numbers shows exactly how much the exponent can be reduced.
Inputs run from 2 to one trillion. All arithmetic uses ordinary integers, and the tool returns a clear error for values outside the range.
How to use
- Enter a modulus n from 2 upward.
- Read lambda(n) from the main result box.
- Compare it with the Euler totient shown beside it.
- Use the factorization to see which prime powers contributed.
- The default n = 8 reproduces the worked example.
- Try n = 15 to see the least common multiple step in action.
Formula
- n
- The modulus being tested.
- p^a
- A prime power in the factorization of n.
- lambda(n)
- The least universal exponent for units modulo n.
The small powers of two are special: lambda(2) = 1 and lambda(4) = 2, matching their totients. From 2^3 onward the value is half the totient. For a product of coprime factors the least common multiple combines the contributions, because the group of units splits into a product of smaller groups.
Worked example
Example: lambda(8)
The page opens with modulus 8.
- Factor 8 as 2^3.
- Compute Euler's totient: phi(8) = 2^2 x (2 - 1) = 4.
- Since the prime is 2 and the exponent is at least 3, halve the totient.
- The contribution is 4 / 2 = 2.
- With only one prime power the least common multiple is 2.
- The tool reports Carmichael value 2, totient 4, and factorization 2^3.
- Check by squaring: every odd residue squared is 1 modulo 8.
Reference table
| n | Factorization | lambda(n) | phi(n) |
|---|---|---|---|
| 2 | 2 | 1 | 1 |
| 3 | 3 | 2 | 2 |
| 4 | 2^2 | 2 | 2 |
| 8 | 2^3 | 2 | 4 |
| 12 | 2^2 x 3 | 2 | 4 |
| 15 | 3 x 5 | 4 | 8 |
| 16 | 2^4 | 4 | 8 |
Limits
- The modulus must be at least 2.
- Inputs above one trillion are rejected to keep factoring quick.
- The tool does not test individual residues, it computes the group exponent.
- Values are exact integers and involve no rounding.
Common mistakes
- Halving the totient for 2^2, which would give a wrong value at 4.
- Taking the product of contributions instead of the least common multiple.
- Assuming lambda always equals phi for prime moduli, where they do match but for a different reason.
- Forgetting that lambda divides phi, never the reverse.
- Applying the even prime rule to odd prime powers.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is lambda(15)?
lambda(3) = 2 and lambda(5) = 4, so lambda(15) = lcm(2, 4) = 4.
What is lambda(12)?
12 = 2^2 x 3 gives contributions 2 and 2, so lambda(12) = 2 while phi(12) = 4.
What is lambda(8)?
For 2^3 the totient is 4 and the Carmichael value is half of that, so lambda(8) = 2.
Questions
What does this function measure?
The smallest exponent that sends every residue coprime to n back to one modulo n.
How does it relate to Euler's totient?
It divides the totient and is often much smaller, especially for numbers with several prime factors.
Why is the power of two special?
The group of units modulo 2^a with a at least 3 is not cyclic, so its exponent is half the group order.
Is the value ever zero?
No. It is a positive exponent for every modulus at least 2.
Where is it applied?
In primality testing, cryptography and the study of Carmichael numbers.
What is the largest modulus?
One trillion, with a clear error message for larger inputs.