Carmichael Number Calculator
Check a composite number against Korselt's rule to see whether it is a Carmichael number.
What it does
A Carmichael number is a composite integer n such that a to the power n minus one is congruent to one modulo n for every integer a coprime to n. In other words, it passes every Fermat primality test even though it is not prime. The first example is 561, which is 3 times 11 times 17.
The numbers are named after Robert Carmichael, who first studied them in the early twentieth century. They are rare but infinite in number, and they show why a primality test needs more than one base.
Korselt's criterion gives a practical test: n must be squarefree and composite, and for every prime p dividing n, p minus one must divide n minus one. This page factors the input and checks those conditions exactly.
The output reports the number of distinct prime factors and the first prime that fails, if any. That makes it clear which part of the criterion broke down.
The input limit is one million, which keeps factoring quick. All decisions use exact integer divisibility.
How to use
- Enter a composite number n from 2 to 1,000,000.
- Read the classification in the main result box.
- Check the count of distinct prime factors beside it.
- If a prime failed, its value is reported.
- The default n = 561 reproduces the worked example.
- Try n = 1105 to confirm the second Carmichael number.
Formula
- n
- The composite integer being tested.
- p
- A prime divisor of n.
- n - 1
- The value each p - 1 must divide.
Korselt's criterion is equivalent to the defining congruence condition and much easier to test. Squarefree composites with at least three prime factors are the only candidates, so a semiprime can never be a Carmichael number.
Worked example
Example: n = 561
The page opens with n = 561.
- Factor 561 as 3 x 11 x 17, so it is squarefree and composite.
- For p = 3, p minus one is 2 and 560 is even.
- For p = 11, p minus one is 10 and 560 is divisible by 10.
- For p = 17, p minus one is 16 and 560 is divisible by 16.
- The tool reports Carmichael number with three distinct primes.
- For 15 the prime 5 fails, so it is not a Carmichael number.
Reference table
| n | Factorization | Korselt test | Carmichael |
|---|---|---|---|
| 15 | 3 x 5 | 5 fails | No |
| 561 | 3 x 11 x 17 | passes | Yes |
| 1105 | 5 x 13 x 17 | passes | Yes |
| 1729 | 7 x 13 x 19 | passes | Yes |
| 2465 | 5 x 17 x 29 | passes | Yes |
Limits
- Inputs above 1,000,000 are rejected to keep factoring quick.
- Primes are excluded by definition.
- The tool reports the first failing prime, not all failures.
- The test is a classification, not a primality proof for other inputs.
Common mistakes
- Testing a prime and expecting a Carmichael verdict.
- Forgetting the squarefree requirement.
- Checking p divides n minus one instead of p minus one.
- Assuming a semiprime can be Carmichael.
- Confusing this with the Carmichael function.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 561 a Carmichael number?
Yes. It is squarefree and 3-1, 11-1 and 17-1 all divide 560.
Is 15 a Carmichael number?
No. The prime 5 fails because 4 does not divide 14.
What is the second Carmichael number?
1105.
Questions
Who are they named after?
Robert Carmichael studied them in the early 1900s.
What does Korselt's criterion say?
Squarefree composite with p minus one dividing n minus one for each prime p.
Are Carmichael numbers infinite?
Yes, that was proved in the twentieth century.
Why do they matter?
They are counterexamples to the Fermat primality test.
Are results exact?
Yes, integer divisibility is used.
What input range is accepted?
Whole numbers from 2 through 1,000,000.