Structural Equivalence: Carmichael + Giuga ↔ giugaSum = -1 #
The key structural result linking Carmichael/Giuga numbers to the Agoh–Giuga
sum. For composite n > 1:
giugaSum n = -1 ↔ IsCarmichaelNumber n ∧ IsGiugaNumber n
Backward direction (⇐) #
If n is both Carmichael and Giuga, then giugaSum n = -1.
Proof sketch via CRT:
nis squarefree, son = ∏ pover its prime factors.- By CRT,
ZMod n ≅ ∏ ZMod p. It suffices to showgiugaSum n ≡ -1 (mod p)for each primep ∣ n. - The sum mod
pdecomposes: values1, …, n-1modpcyclen/ptimes through the nonzero residues, so∑_{i=1}^{n-1} i^{n-1} ≡ (n/p) · ∑_{k=1}^{p-1} k^{n-1} (mod p). - By the Carmichael/Korselt property,
(p-1) ∣ (n-1), so eachk^{n-1} ≡ 1 (mod p), giving the inner sum= p - 1 ≡ -1 (mod p). - By the Giuga property,
p ∣ (n/p - 1), son/p ≡ 1 (mod p). - The product is
1 · (-1) = -1 (mod p).
Forward direction (⇒) #
If giugaSum n = -1 for composite n > 1, then n is both Carmichael and
Giuga. This direction is harder and is deferred.
Structural backward direction. Carmichael + Giuga ⟹ giugaSum = -1.
The proof uses CRT to reduce to prime-by-prime verification, then applies Fermat's little theorem (via Korselt) and the Giuga divisibility condition.