Carmichael Function Calculator

Input

Carmichael function lambda(100)20
Factorization2^2 x 5^2
Prime-power lambdas2, 20
Euler totient phi(n)40
How this was calculated
  1. Factor 100 into prime powers: 2^2 x 5^2.
  2. The Carmichael function of a prime power p^k is (p - 1) x p^(k-1) for odd primes, with a halved rule for powers of two.
  3. The prime-power values here are 2, 20, and lambda of the whole number is their least common multiple.
  4. So lambda(100) = 20, against Euler's totient phi(100) = 40: every unit raised to the lambda power is 1 modulo n, and no smaller universal exponent works.

The Carmichael function calculator finds lambda(n), the smallest exponent that sends every unit modulo n to 1. You enter a value of n, and the calculator returns lambda(n) along with the prime factorization behind it. The result is often smaller than Euler's totient, which counts how many numbers are coprime to n: lambda(n) always divides the totient, but it can be much smaller. For example, lambda(100) = 20 against a totient of 40, lambda(15) = 4 against a totient of 8, and lambda(561) = 80 against a totient of 320. That last case is notable because 561 is the smallest Carmichael number, a composite that passes the Fermat primality test for every coprime base.

The calculator follows the standard definition: it computes lambda from the prime factorization, giving each prime power its own lambda value and combining those results by least common multiple. That is the accepted method for this calculation, and every answer on the page traces back to it. Here you will find the formula, step-by-step workings, worked examples such as the ones above, and the sources behind the definition, so you can check each result yourself rather than take it on trust.

Worked examples

Lambda of 100

(100)

Carmichael function lambda(100)20
Factorization2^2 x 5^2
Prime-power lambdas2, 20
Euler totient phi(n)40

Lambda of 15

(15)

Carmichael function lambda(15)4
Factorization3 x 5
Prime-power lambdas2, 4
Euler totient phi(n)8

The smallest Carmichael number

(561)

Carmichael function lambda(561)80
Factorization3 x 11 x 17
Prime-power lambdas2, 10, 16
Euler totient phi(n)320

A sharper exponent than Euler's

Euler's totient φ(n) counts the units modulo n — the residues coprime to n — and Euler's theorem says every one of them satisfies a^φ(n) ≡ 1 (mod n). That makes φ(n) a valid exponent for the whole group of units. But valid does not mean smallest. The exponent of the multiplicative group modulo n is the least positive integer that sends every unit to 1 at once, and that least value is the Carmichael function λ(n). Because λ(n) is by definition the smallest such exponent, it always divides φ(n). Often it divides it strictly, and sometimes the gap is large.

The reason is that φ(n) multiplies together the sizes of the pieces the group splits into, while the exponent only needs to accommodate the longest cycle among them. A product of numbers can be far larger than their least common multiple. That is exactly what happens modulo n: the units decompose into components attached to the prime powers in the factorization of n, and the exponent of the whole group is governed by the slowest of those components rather than by their combined size. A Carmichael function calculator exploits this structure: it takes the prime factorization of n, assigns each prime power its own λ value, and combines those values by least common multiple. No search over residues is required, and the result is exact.

Concrete numbers make the shrinkage visible. Modulo 100, the totient is 40, yet λ(100) = 20 — every unit raised to the 20th power already returns to 1, so half of Euler's exponent is wasted. Modulo 15 the totient is 8 while λ(15) = 4. The most striking illustration is 561, where the totient is 320 but λ(561) = 80: a factor of four separates the true exponent from Euler's bound. In each case the smaller value still works for every coprime base, and no smaller positive exponent does.

The case 561 deserves its own note, because 561 is the smallest Carmichael number — a composite that passes the Fermat primality test for every base coprime to it. A Fermat test checks whether a^(n−1) ≡ 1 (mod n) for a chosen base; for 561 that congruence holds for all coprime bases even though 561 is not prime. The explanation is precisely the exponent: λ(561) = 80 divides 560 = 561 − 1, so the test's exponent is a multiple of the group's true exponent and can never expose the compositeness. This is why the Carmichael function matters beyond pure group theory: it marks the boundary of what Fermat-style tests can detect.

λ(n) is the smallest exponent that sends every unit modulo n to 1. It always divides φ(n) — and the gap can be wide: λ(100) = 20 against φ(100) = 40, λ(15) = 4 against φ(15) = 8, and λ(561) = 80 against φ(561) = 320.

Prime powers, then a least common multiple

The Carmichael function is built in two stages. First, the prime factorization of n is written out, and each prime power in that factorization gets its own lambda value. Then those separate values are combined by taking their least common multiple. That is the whole method, and a carmichael function calculator follows exactly this path: factor, evaluate each prime power, then reduce the pieces to a single LCM.

Take n = 100. Its factorization is 2^2 x 5^2, so there are two prime powers to handle: 4 and 25. The prime-power lambda for 4 is 2, and the prime-power lambda for 25 is 20. Neither number is the final answer on its own, because the definition of lambda(n) requires one exponent that works for every unit modulo n at once. The least common multiple of 2 and 20 is 20, so lambda(100) = 20.

That result is worth comparing with Euler's totient for the same number. The totient of 100 is 40, and lambda(100) = 20 is exactly half of it. This is not a coincidence of the example: the Carmichael function always divides Euler's totient, and it can be much smaller. The totient counts the units modulo n; lambda asks for the smallest exponent that sends every one of those units to 1, which is a stricter and often far cheaper requirement.

The same two-stage pattern explains other values. For 15, the factorization splits into prime powers whose lambda values combine to give lambda(15) = 4, against a totient of 8. For 561, the combination gives lambda(561) = 80, against a totient of 320 — a factor of four smaller. That last example carries extra weight: 561 is the smallest Carmichael number, a composite that passes the Fermat primality test for every coprime base. In other words, a number can look prime to that test while lambda still reveals its composite structure, which is why the function matters in primality testing and in choosing exponents for modular arithmetic.

The practical lesson is to never multiply the prime-power values together. Multiplying would overcount, because the exponent only has to work simultaneously for all the units, and the least common multiple is precisely the smallest exponent that does. Factorization first, prime-power lambdas second, least common multiple last — in that order, the arithmetic stays short even when n grows.

nFactorizationPrime-power lambdaslambda(n)Totient
1002^2 x 5^22 and 202040
15——48
561——80320
For 100 = 2^2 x 5^2, the prime-power lambdas are 2 and 20. Their least common multiple is 20, so lambda(100) = 20 — half of the totient of 40.

The halved rule for powers of two

Most of the Carmichael function's rules follow a tidy pattern: for an odd prime power, lambda is simply the totient, and the values combine by least common multiple. Powers of two break that pattern. The reason is that the multiplicative group of units modulo 2^k stops being cyclic once k reaches 3, so there is no single element whose powers run through every unit. The Carmichael function has to account for that loss of structure, and it does so with a special rule that halves the exponent for 8 and above.

The small cases are easy to state. For n = 2, the only unit is 1, so lambda(2) = 1. For n = 4, the units are 1 and 3, and 3 squared is 9, which is 1 modulo 4, so lambda(4) = 2. Both of these match Euler's totient, which is 1 and 2 respectively. The divergence begins at 8. Modulo 8 the units are 1, 3, 5 and 7, and every one of them squares to 1, so lambda(8) = 2, while the totient is 4. From that point on, lambda(2^k) = 2^(k-2) for k at least 3, exactly half of the totient 2^(k-1).

This halving is the rule people most often want checked, and it is where a carmichael function calculator earns its keep. For n = 16, the totient is 8 and lambda is 4. For n = 32, the totient is 16 and lambda is 8. The pattern holds without exception for higher powers. Intuitively, the unit group modulo 2^k splits into two cyclic pieces, one generated by -1 and one by 5, and the largest order available is the least common multiple of their lengths, which comes out to half the totient.

The halved value still obeys the general definition: it is the smallest exponent that sends every unit modulo 2^k to 1, and it divides the totient. It also feeds correctly into the least-common-multiple step when a number has other prime factors. Because lambda is built from prime powers and combined by LCM, a factor of 2^k contributes its halved value rather than the full totient, and that smaller contribution can pull the overall answer down. This is one reason lambda(n) can be much smaller than the totient even for numbers that are not themselves powers of two.

The contrast with odd prime powers is worth keeping in mind. There the group of units is cyclic, so lambda equals the totient and no halving occurs. The power-of-two rule is the single exception in the prime-power step, and it is the piece most likely to be misremembered or skipped in a hand calculation. Once it is applied, the rest of the procedure is routine: factor n, take each prime power's lambda, and combine them by least common multiple.

  • lambda(2) = 1, matching the totient.
  • lambda(4) = 2, matching the totient.
  • lambda(8) = 2, while the totient is 4.
  • For k at least 3, lambda(2^k) = 2^(k-2), half of the totient 2^(k-1).
  • The halved value still divides the totient and combines with other prime-power values by least common multiple.
Powers of two are the one place in the prime-power step where the group of units is not cyclic for k of 3 or more, so lambda(2^k) is half the totient rather than equal to it.

Carmichael numbers and primality tests

The Carmichael function takes its name from a special class of composite numbers that can fool one of the oldest checks for primality. A Carmichael number is a composite n that passes the Fermat primality test for every base coprime to n — meaning that for each such base a, raising a to the power n − 1 leaves a remainder of 1 modulo n, exactly as a prime would. The smallest example is 561. A quick Fermat check on 561 would suggest it is prime, yet 561 factors as 3 × 11 × 17. This is why anyone using a carmichael function calculator should understand that the function and the numbers named after it are two sides of the same idea: the function measures the true exponent behavior of units modulo n, and Carmichael numbers are the composites where that behavior mimics a prime closely enough to fool a basic test.

The connection is visible in the numbers. For n = 561, the Carmichael function gives lambda(561) = 80, while Euler's totient gives 320 — a factor of four larger. For a prime p, lambda(p) equals p − 1, the same as the totient, so the two agree. For 561 they diverge sharply, and that gap is the signature of a Carmichael number. A related small case shows the same pattern: lambda(15) = 4 against a totient of 8, and lambda(100) = 20 against a totient of 40. In each case lambda is the smallest exponent that sends every unit modulo n to 1, it divides the totient, and it can be much smaller. The function is computed from the prime factorization, with each prime power contributing its own lambda value and the results combined by least common multiple — which is exactly how the 80 for 561 arises from its three prime factors.

This distinction matters far beyond number theory puzzles. In RSA key generation, the private exponent is built from the exponent of the multiplicative group modulo the product of two primes. Using lambda instead of the totient can yield a smaller private exponent, which means faster decryption for the same modulus size. But the security argument depends on knowing the factorization of the modulus; if the modulus were secretly a Carmichael number or had a structure that made lambda much smaller than expected, the effective key space would shrink. Proper RSA key generation therefore tests candidate primes and avoids weak composite moduli, and the Carmichael function is the clean way to state what “weak” means here.

Primality testing more broadly has moved past the Fermat test precisely because of numbers like 561. Modern tests such as Miller–Rabin use additional structure, and the Carmichael function helps explain why: a composite n whose lambda(n) divides n − 1 is a Carmichael number, and such n will pass the simple Fermat check for all coprime bases. Knowing lambda for a candidate tells you how large the exponent group really is, and whether a test based on exponentiation can be trusted. That is the practical value of computing lambda alongside the totient — the two numbers together reveal whether a modulus behaves like a prime or merely pretends to.

561 is the smallest Carmichael number: a composite that passes the Fermat primality test for every coprime base. Its lambda is 80, against a totient of 320.

FAQs

What is the Carmichael function?

The Carmichael function, written lambda(n), is the smallest positive exponent e such that a^e is 1 modulo n for every a coprime to n. In other words, it gives the smallest exponent that works for all units modulo n at once, rather than for one specific value of a.

How does it differ from Euler's totient?

Euler's totient counts the units, meaning how many numbers below n are coprime to n. The Carmichael function is the group's exponent, the smallest exponent that sends every unit to 1. The two can differ: lambda(100) = 20 while the totient of 100 is 40.

How is lambda(n) calculated?

Factor n into prime powers, take lambda of each prime power, and combine those values with the least common multiple. The prime power values follow set rules, so the work comes down to factoring n, evaluating each prime power piece, and then taking the LCM of the results.

What is lambda(561)?

lambda(561) is 80. Since 561 = 3 x 11 x 17, it is the smallest Carmichael number, and its lambda is far below its totient of 320. That gap is exactly why Carmichael numbers behave unusually: every coprime base returns to 1 well before the totient would suggest.

Why does RSA use it?

In RSA, private exponents can be computed modulo lambda(n) instead of the totient, giving the smallest working exponent. A smaller private exponent means faster decryption and a smaller key component, while the underlying correctness of the scheme is preserved because lambda divides the totient.

Is lambda(n) ever equal to the totient?

Yes. For primes, twice odd primes and a few other cases the two coincide. In general lambda divides the totient, so equality is the special case and a smaller lambda is what you see otherwise. That relationship is why lambda is often described as a refinement of the totient.

Sources

Related calculators

Euler's Totient Calculator
Euler's totient φ(n) — how many integers up to n are coprime to n — from the distinct prime factors of n.
Möbius Function Calculator
The Möbius function mu(n) from the prime factorization of n: zero for a squared prime factor, otherwise plus or minus one by the factor count.
Modular Exponentiation Calculator
Compute a power modulo m exactly with binary exponentiation, showing the squaring chain step by step.