Carmichael Numbers

lean4-proofnumber-theoryvisualization
n is Carmichael    n is composite and ana(modn) for all an \text{ is Carmichael} \iff n \text{ is composite and } a^n \equiv a \pmod{n} \text{ for all } a

Statement

A Carmichael number is a composite integer n>1n > 1 such that ana(modn)a^n \equiv a \pmod{n} for every integer aa — mimicking Fermat's Little TheoremFermat's Little Theoremapa(modp)a^p \equiv a \pmod{p}For prime p, a^p is congruent to a mod pRead more → despite not being prime.

Korselt's criterion characterises them: nn is a Carmichael number if and only if

  1. nn is squarefree (no prime square divides nn), and
  2. (p1)(n1)(p - 1) \mid (n - 1) for every prime pnp \mid n.

The smallest Carmichael number is 561=3×11×17561 = 3 \times 11 \times 17.

Visualization

Verification of Korselt's criterion for the four smallest Carmichael numbers:

nnFactorisationSquarefree?(p1)(n1)(p-1) \mid (n-1)?
5613×11×173 \times 11 \times 17Yes25602\mid 560, 1056010\mid 560, 1656016\mid 560 — Yes
11055×13×175 \times 13 \times 17Yes411044\mid 1104, 12110412\mid 1104, 16110416\mid 1104 — Yes
17297×13×197 \times 13 \times 19Yes617286\mid 1728, 12172812\mid 1728, 18172818\mid 1728 — Yes
24655×17×295 \times 17 \times 29Yes424644\mid 2464, 16246416\mid 2464, 28246428\mid 2464 — Yes

Check for 561: n1=560=24×5×7n - 1 = 560 = 2^4 \times 5 \times 7.

  • p=3p = 3: p1=2p - 1 = 2, and 25602 \mid 560. Yes.
  • p=11p = 11: p1=10p - 1 = 10, and 1056010 \mid 560 (560=56×10560 = 56 \times 10). Yes.
  • p=17p = 17: p1=16p - 1 = 16, and 1656016 \mid 560 (560=35×16560 = 35 \times 16). Yes.

Proof Sketch

  1. If n=p1pkn = p_1 \cdots p_k is squarefree and (pi1)(n1)(p_i - 1) \mid (n-1) for each ii, then for any aa: if piap_i \mid a then pianp_i \mid a^n; if piap_i \nmid a then api11(modpi)a^{p_i - 1} \equiv 1 \pmod{p_i} by Fermat's Little TheoremFermat's Little Theoremapa(modp)a^p \equiv a \pmod{p}For prime p, a^p is congruent to a mod pRead more →, so an=a(api1)(n1)/(pi1)a(modpi)a^n = a \cdot (a^{p_i - 1})^{(n-1)/(p_i-1)} \equiv a \pmod{p_i}.
  2. By the Chinese Remainder TheoremChinese Remainder TheoremZ/mnZZ/mZ×Z/nZ\mathbb{Z}/mn\mathbb{Z} \cong \mathbb{Z}/m\mathbb{Z} \times \mathbb{Z}/n\mathbb{Z}Simultaneous congruences with coprime moduli have a unique solution mod their productRead more →, ana(modn)a^n \equiv a \pmod{n}.
  3. Conversely, if nn is not squarefree or some (pi1)(n1)(p_i - 1) \nmid (n-1), one can exhibit an aa with an≢aa^n \not\equiv a.
  4. Korselt (1899) proved this characterisation; Robert Carmichael verified 561561 in 1910.

Connections

Carmichael numbers demonstrate that Fermat's primality test (checking an11(modn)a^{n-1} \equiv 1 \pmod{n}) is not conclusive. The Fundamental Theorem of ArithmeticFundamental Theorem of Arithmeticn=p1a1p2a2pkakn = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k}Every integer greater than 1 has a unique prime factorizationRead more → underpins Korselt's squarefree condition; the Chinese Remainder Theorem (see Chinese Remainder TheoremChinese Remainder TheoremZ/mnZZ/mZ×Z/nZ\mathbb{Z}/mn\mathbb{Z} \cong \mathbb{Z}/m\mathbb{Z} \times \mathbb{Z}/n\mathbb{Z}Simultaneous congruences with coprime moduli have a unique solution mod their productRead more →) patches the local conditions together.

Lean4 Proof

/-- 561 = 3 * 11 * 17 — the factorisation of the smallest Carmichael number. -/
theorem carmichael_561_factored : 561 = 3 * 11 * 17 := by norm_num

/-- 561 is squarefree: no prime squared divides it. -/
theorem carmichael_561_squarefree : Squarefree 561 := by decide