Carmichael Number Calculator

Check a composite number against Korselt's rule to see whether it is a Carmichael number.

Math and PercentUpdated 2026-11-182 min read
Carmichael Number Calculator
A whole number from 2 to 1,000,000.
Classification
...
Distinct prime factors...
First failing prime...

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

  1. Enter a composite number n from 2 to 1,000,000.
  2. Read the classification in the main result box.
  3. Check the count of distinct prime factors beside it.
  4. If a prime failed, its value is reported.
  5. The default n = 561 reproduces the worked example.
  6. Try n = 1105 to confirm the second Carmichael number.

Formula

n is Carmichael when n is composite, squarefree, and for every prime p dividing n, (p - 1) divides (n - 1)
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.

  1. Factor 561 as 3 x 11 x 17, so it is squarefree and composite.
  2. For p = 3, p minus one is 2 and 560 is even.
  3. For p = 11, p minus one is 10 and 560 is divisible by 10.
  4. For p = 17, p minus one is 16 and 560 is divisible by 16.
  5. The tool reports Carmichael number with three distinct primes.
  6. For 15 the prime 5 fails, so it is not a Carmichael number.

Reference table

Carmichael numbers
nFactorizationKorselt testCarmichael
153 x 55 failsNo
5613 x 11 x 17passesYes
11055 x 13 x 17passesYes
17297 x 13 x 19passesYes
24655 x 17 x 29passesYes

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.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.