How many primes would a Giuga counterexample need?

AI-generated · No human mathematician has yet refereed the proof.

Giuga guessed that a simple sum test picks out exactly the primes among the numbers from 2 up. Lean proves unconditionally that any composite passing the test needs at least 8,138 distinct prime factors and exceeds 10⁴⁰⁷⁴⁷.

Every composite number n ≥ 2 for which 1ⁿ⁻¹ + 2ⁿ⁻¹ + … + (n − 1)ⁿ⁻¹ leaves remainder n − 1 on division by n has at least 8,138 distinct prime factors and satisfies n > 10⁴⁰⁷⁴⁷ (at least 40,748 decimal digits), with exact normal-set minima 8,135 factors and 40,733 digits and seven-rule local-class minimum 8,138 factors and 40,748 to 40,750 digits.

For a prime n each term of 1ⁿ⁻¹ + 2ⁿ⁻¹ + … + (n − 1)ⁿ⁻¹ leaves remainder 1 on division by n, so the sum leaves remainder n − 1, and Giuga conjectured in 1950–1951 that no composite number does this. Borwein, Maitland and Skerritt showed in 2013 that a counterexample needs at least 4,771 prime factors and 19,908 digits. Using a five-leaf adaptive price split below 17 checked inside Lean with no external certificates, Lean lifts this to 8,138 prime factors and at least 40,748 digits.

Edge prices and a five-leaf kernel split lift Giuga bounds to 8,138 primes and 40,748 digits

Walkthrough: 7 of 7 main results in Lean

Both prior foundations below are re-proved directly inside Lean here rather than assumed externally.

Published inputs

  • Giuga (1951) (original article unread) (Re-proved in Lean): Showed that the prime factors of any counterexample form a normal odd prime set with reciprocal sum above one (known here through later work).
  • Borwein, Borwein, Borwein & Girgensohn (1996) (Re-proved in Lean): Gave the count congruence modulo four: for value one, the number of prime factors is 2 modulo 4.

What this paper adds

  • Edge prices, local rules & 578-prime floor: Forbidden-pair prices & mod-8 count rule
  • Five-leaf kernel split below 17: Pure-kernel dual certificates across all 5 leaves
  • Exact minima & ceiling witnesses: Normal-set and seven-rule local minima in Lean

At least 8,138 distinct prime factors and at least 40,748 decimal digits in Lean

Every composite counterexample to Giuga’s conjecture has at least 8,138 distinct prime divisors and satisfies n > 10⁴⁰⁷⁴⁷, matching the exact local-class cardinality ceiling.

All 7 of 7 main results proved unconditionally inside Lean 4 with zero external certificates.

Listed as open in the paper

  • Giuga’s 1950–1951 conjecture that no composite counterexample exists remains open.
  • Pinning the seven-rule local digit minimum inside {40,748, 40,749, 40,750} to a single digit count remains open.

Adjacent prior work (not used as inputs)

  • Bedocchi (1985)
  • Borwein, Maitland & Skerritt (2013)
  • Mavrotheris (2026) (not fully read)
  • S. Schlesinger, agoh-giuga-conjecture

Why a counterexample needs at least 9 primes

The test: for n = 7, each of 1⁶, 2⁶, …, 6⁶ leaves remainder 1 on division by 7, so the sum leaves remainder 6 = n − 1. For n = 9, which is not prime, the sum 1⁸ + 2⁸ + … + 8⁸ leaves remainder 6, not 8, so 9 fails the test, as Giuga expected.

A number that passed without being prime would be odd and a product of different primes, and the fractions 1/p over its primes p would add up to more than 1. Also no prime q of it could divide r − 1 for another prime r of it. So 3 and 7 cannot both be used (3 divides 6), and neither can 5 and 11 (5 divides 10).

Write each 1/p as 1/13 plus a bonus 1/p − 1/13. Only the primes below 13, which are 3, 5, 7 and 11, have a positive bonus, and from each forbidden pair at most the larger bonus counts: 1/3 − 1/13 = 10/39 and 1/5 − 1/13 = 8/65. Together that is 74/195.

So the sum of the 1/p is at most (number of primes)/13 + 74/195. For it to pass 1, the number of primes must exceed 13 · (1 − 74/195) = 121/15, which is about 8.07. So there are at least 9 primes.

Lean checks this calculation. The same idea, with the odd primes below 3,000 and 312 priced pairs (108 when 3 is used) checked by computer inside Lean, gives at least 575 primes and then at least 578.

The interactive page explains each key step in full.

From a power sum to a set of primes

A counterexample is a number n ≥ 2, not prime, whose power sum 1ⁿ⁻¹ + … + (n − 1)ⁿ⁻¹ leaves remainder n − 1 on division by n. Lean proves that for such n this holds exactly when every prime p dividing n has both p − 1 and p dividing n/p − 1. So a counterexample is odd, has no repeated prime factor, and its primes form a normal set (no q divides r − 1), with the sum of n/p over them equal to v·n + 1 for a whole number v ≥ 1, so the fractions 1/p add up to more than 1. Lean holds some of these pieces twice, and this is why. Lean states the theorems in a separate statement file, with its own copy of the definitions, so that what is claimed can be checked without reading any proof; the library proves them. Where a piece is in both files, the library's copy is marked as the library's.

  • The prime factors of a counterexample form a normal set of odd primes
  • n is a counterexample to Giuga's conjecture
  • P is a normal set of odd primes
  • n meets the Carmichael condition
  • n meets the Giuga condition
  • A number n ≥ 2 that is not prime is a counterexample exactly when it meets both conditions
  • A counterexample has a value v
  • The reciprocals of the prime factors of a counterexample add up to more than 1
  • The power sum modulo a prime
  • The sum modulo a prime factor

Rules a counterexample must obey

Write v for the whole number with ∑ n/p = v·n + 1. Lean proves that the number of prime factors is v + 1 modulo 8, that the prime factors add up to v + n modulo 8, and that the number of prime factors leaving remainder 3 on division by 4 is 0 or 1 modulo 4. When v = 1, leaving out any one prime factor brings the sum of the other reciprocals below 1.

  • The number of prime factors of a counterexample of value v is v + 1 modulo 8

    If n is a counterexample and the sum of n/p over its prime factors is v·n + 1, then the number of prime factors leaves the same remainder on division by 8 as v + 1.

    theorem GiugaChallenge.giuga_card_mod_eight {n : ℕ} {v : ℕ} (hn : IsGiugaCounterexample n) (hv : ∑ p ∈ n.primeFactors, n / p = v * n + 1) :
      n.primeFactors.card ≡ v + 1 [MOD 8]
  • The prime factors of a counterexample of value v add up to v + n modulo 8

    If n is a counterexample and the sum of n/p over its prime factors p is v·n + 1, then the prime factors add up to a number that leaves the same remainder on division by 8 as v + n.

    theorem GiugaChallenge.giuga_residue_mod_8 {n : ℕ} {v : ℕ} (hn : IsGiugaCounterexample n) (hv : ∑ p ∈ n.primeFactors, n / p = v * n + 1) :
      ∑ p ∈ n.primeFactors, p ≡ v + n [MOD 8]
  • The number of prime factors leaving remainder 3 on division by 4 is 0 or 1 modulo 4

    If n is a counterexample, the number of its prime factors that leave remainder 3 on division by 4 itself leaves remainder 0 or 1 on division by 4.

    theorem GiugaChallenge.giuga_reciprocity_rule {n : ℕ} (hn : IsGiugaCounterexample n) :
      {p ∈ n.primeFactors | p % 4 = 3}.card % 4 = 0 ∨ {p ∈ n.primeFactors | p % 4 = 3}.card % 4 = 1
  • For a counterexample of value 1, the reciprocals of its prime factors add up to less than 1 + 1/p for each prime factor p

    If n is a counterexample with the sum of n/p over its prime factors equal to n + 1, and p is a prime factor of n, then the sum of 1/q over all prime factors q is less than 1 + 1/p. So leaving out p brings the sum below 1.

    theorem GiugaChallenge.giuga_exactness_rule {n : ℕ} (hn : IsGiugaCounterexample n) (hv1 : ∑ p ∈ n.primeFactors, n / p = n + 1) {p : ℕ} (hp : p ∈ n.primeFactors) :
      ∑ q ∈ n.primeFactors, 1 / ↑q - 1 < 1 / ↑p
  • For odd n with no repeated prime factor and of value v, the number of prime factors is v + 1 modulo 4
  • The sum minus the product of a set of odd numbers, modulo 8

Prices on forbidden pairs

Fix the primes of a normal set below a cut and call the rest its tail. Each tail prime x gets a weight, such as 1/x − 1/Λ, and each forbidden pair q < r with q dividing r − 1 gets a price of at least 0. Because a normal tail never holds both primes of a pair, its total weight is at most the sum of the prices plus, for each prime, the weight its prices leave uncovered. Lean turns this into lower bounds on the number of tail primes and on the sum of their logarithms, and combines them over every prefix.

  • Prices bound the number of tail primes

    Let T be a normal set of tail primes for the prefix S at a cut, whose reciprocals add up to more than the need of S. Take Λ > 0, a set U holding every tail prime below Λ, forbidden pairs E inside U, and prices η ≥ 0 on them. Then T has more than Λ·(N − B) members, where N is the need of S, B is the price bound of U, E, w and η, and w(x) = 1/x − 1/Λ.

    theorem GiugaChallenge.lemma_w_edge_dual_count {S : Finset ℕ} {T : Finset ℕ} {U : Finset ℕ} {E : Finset (ℕ × ℕ)} {p_d : ℕ} {Λ : ℝ} {η : ℕ × ℕ → ℝ} (hT : IsNormalOddPrimeSet T) (hTail : ∀ x ∈ T, IsTailPrime S p_d x) (hneed : need S < ∑ x ∈ T, 1 / ↑x) (hΛ : 0 < Λ) (hU : ∀ (x : ℕ), IsTailPrime S p_d x → ↑x < Λ → x ∈ U) (hE : ∀ e ∈ E, e.1 ∈ U ∧ e.2 ∈ U ∧ IsConflictEdge e.1 e.2) (hη : ∀ e ∈ E, 0 ≤ η e) :
      Λ * (need S - edgeDualUB U E (fun x => 1 / ↑x - 1 / Λ) η) < ↑T.card
  • Prices bound the size of the tail

    Under the same conditions, but with Λ ≥ 1 and 0 < μ ≤ Λ·ln Λ, the sum of ln x over T is more than μ·N − B, where N is the need of S, B is the price bound of U, E, w and η, and now w(x) = μ/x − ln x.

    theorem GiugaChallenge.lemma_w_edge_dual_prod {S : Finset ℕ} {T : Finset ℕ} {U : Finset ℕ} {E : Finset (ℕ × ℕ)} {p_d : ℕ} {Λ : ℝ} {μ : ℝ} {η : ℕ × ℕ → ℝ} (hT : IsNormalOddPrimeSet T) (hTail : ∀ x ∈ T, IsTailPrime S p_d x) (hneed : need S < ∑ x ∈ T, 1 / ↑x) (hΛ : 1 ≤ Λ) (hμ0 : 0 < μ) (hμ : μ ≤ Λ * Real.log Λ) (hU : ∀ (x : ℕ), IsTailPrime S p_d x → ↑x < Λ → x ∈ U) (hE : ∀ e ∈ E, e.1 ∈ U ∧ e.2 ∈ U ∧ IsConflictEdge e.1 e.2) (hη : ∀ e ∈ E, 0 ≤ η e) :
      μ * need S - edgeDualUB U E (fun x => μ / ↑x - Real.log ↑x) η < ∑ x ∈ T, Real.log ↑x
  • Count bounds over a full list of prefixes give a count bound for every normal set whose reciprocals add up to more than 1

    Let F contain every normal set of odd primes below a cut. Suppose each S in F carries a number Λ(S) > 0, a set U(S), forbidden pairs E(S) and prices η(S) ≥ 0 as in the count bound from prices, with B(S) − 1 at most Λ(S) times the difference between the need of S and its price bound. Then every normal set of odd primes whose reciprocals add up to more than 1 has at least as many members as the smallest value of |S| + B(S) over F.

  • Prices and a known count bound the size of the tail

    Let T be a normal set of tail primes for S at a cut whose reciprocals add up to more than the need of S, and with at least K members. Take μ > 0, ν ≥ 0 and C > 0 with μ/C + ν − ln C ≤ 0, a set U holding every tail prime below C, forbidden pairs E inside U and prices η ≥ 0. Then μ·N + ν·K − B is less than the sum of ln x over T, where N is the need of S, B is the price bound of U, E, w and η, and w(x) = μ/x + ν − ln x.

    theorem GiugaChallenge.lemma_w_refinement2_strict {S : Finset ℕ} {T : Finset ℕ} {U : Finset ℕ} {E : Finset (ℕ × ℕ)} {p_d : ℕ} {K : ℕ} {μ : ℝ} {ν : ℝ} {C : ℝ} {η : ℕ × ℕ → ℝ} (hT : IsNormalOddPrimeSet T) (hTail : ∀ x ∈ T, IsTailPrime S p_d x) (hneed : need S < ∑ x ∈ T, 1 / ↑x) (hK : K ≤ T.card) (hμ : 0 < μ) (hν : 0 ≤ ν) (hC : 0 < C) (hfC : μ / C + ν - Real.log C ≤ 0) (hU : ∀ (x : ℕ), IsTailPrime S p_d x → ↑x < C → x ∈ U) (hE : ∀ e ∈ E, e.1 ∈ U ∧ e.2 ∈ U ∧ IsConflictEdge e.1 e.2) (hη : ∀ e ∈ E, 0 ≤ η e) :
      μ * need S + ν * ↑K - edgeDualUB U E (fun x => μ / ↑x + ν - Real.log ↑x) η < ∑ x ∈ T, Real.log ↑x
  • The refined size form with the count lifted to fit modulo 4

    Let P be a normal set of odd primes whose reciprocals add up to more than 1 and whose size leaves remainder 2 on division by 4. Let S be its members below a cut and K at most the number of the others. With μ ≥ 0 and the other choices as in the refined size form, the logarithm of the product of P is at least (the sum of ln s over S) + μ·N + ν·K' − B, where N is the need of S, B is the price bound of U, E, w and η, and K' is the lift of K for |S|.

  • The need of a set S
  • q and r form a forbidden pair
  • x is a tail prime for the prefix S at a cut
  • The price bound of U, E, w and η
  • The lift of K
  • Every normal set of odd primes whose reciprocals add up to more than 1 has at least 9 members
  • A contains no pair from E
  • A normal set contains no forbidden pair
  • A pair-free subset of U weighs at most the price bound
  • The weight of a normal set inside U is at most the price bound

At least 578 primes and more than 1,803 digits, with no outside input

Splitting at 5, a normal set either contains 3 or not, and for each case Lean runs a price check with cut 3,000 (312 priced pairs without 3, 108 with 3), which gives at least 575 members. If v ≥ 2 the reciprocals add up to more than 2, and the bound for sums above 2, with fewer than 575 odd primes below 4,211, gives at least 4,786; if v = 1 the count is 2 modulo 8, so at least 578. Then n is at least the product of the 574 odd primes below 4,211 times 4,211⁴, which Lean computes to exceed 10¹⁸⁰³.

  • Every counterexample has at least 578 different prime factors

    If n is a counterexample to Giuga's conjecture, then n has at least 578 different prime factors.

  • Every counterexample is larger than 10¹⁸⁰³

    If n is a counterexample to Giuga's conjecture, then n > 10¹⁸⁰³, so n has at least 1,804 digits.

  • Every normal set of odd primes whose reciprocals add up to more than 1 has at least 575 members

    If P is a normal set of odd primes and the sum of 1/p over P is more than 1, then P has at least 575 members.

  • A count bound for sums above 1 gives one for sums above 2

    Suppose every normal set of odd primes whose reciprocals add up to more than 1 has at least N₁ members, and fewer than N₁ odd primes lie below q. Then every normal set of odd primes whose reciprocals add up to more than 2 has at least N₁ + q members.

  • A passed price check with target K gives at least K + 1 tail primes
  • The price check passes for the empty prefix with target 574
  • The price check passes for the prefix {3} with target 586
  • The unpacked prices on a normal set add up to at most the total price
  • There are fewer than 575 odd primes below 4,211
  • The sieve's bit count below 4,211 is 574
  • The product of the survivors below 4,211, times 4,211⁴, exceeds 10¹⁸⁰³
  • A lower bound on a product from its small members and its count
  • The odd numbers below 83,341 that the sieve leaves
  • Every odd prime below 83,341 survives the sieve
  • The number of 1 digits below place 65,536 is at most the 16-step bit count

Two sets of 8,135 and 8,138 primes

Lean builds the 8,135-prime normal witness G (40,733 digits), the 8,138-prime seven-rule ceiling witness W (40,751 digits, deletion at most 1), and the sharper 8,138-prime witness W_321169 (40,750 digits, strict deletion below 1, cofactor at 5 congruent to 2 mod 5). Every primality, normality, and product check runs inside Lean.

  • There is a set of 8,138 odd primes that obeys seven local rules

    There is a normal set W of 8,138 odd primes, without 3, whose reciprocals add up to more than 1, such that leaving out any one member brings that sum to at most 1, the number of members leaving remainder 3 on division by 4 is 0 or 1 modulo 4, the sum of the members leaves the same remainder on division by 8 as 1 plus their product, and the product lies between 10⁴⁰⁷⁵⁰ and 10⁴⁰⁷⁵¹.

  • There is a normal set of 8,135 odd primes whose reciprocals add up to more than 1

    There is a normal set G of 8,135 odd primes such that the sum of 1/p over G is more than 1, both as an exact fraction and as a real number, and the product of its members lies between 10⁴⁰⁷³² and 10⁴⁰⁷³³, so it has 40,733 digits.

  • Verified properties of W_321169
  • The facts about W
  • The facts about G
  • The bundle check passes
  • What a passed bundle check proves about G and W
  • The computed summary describes the packed set
  • A number the sieve leaves up to 321,143 is prime

Five-leaf split: 8,138 primes and 40,748 digits inside Lean

Splitting every normal odd prime set below 17 into five adaptive leaves ({3}, empty below 7, {5}, {5, 7}, and {5, 7, 13}), Lean checks all five dual-price certificates directly inside the kernel. That proves unconditionally that every normal odd prime set with reciprocal sum above 1 has at least 8,135 primes and product above 10⁴⁰⁷³², and product above 10⁴⁰⁷⁴⁷ when its size leaves remainder 2 on division by 4. A counterexample of value 1 has such a size, and the bound for sums above 2 covers value 2 or more; that gives at least 8,138 prime factors and n > 10⁴⁰⁷⁴⁷ (at least 40,748 digits). With the sets G and W_321169 it gives the exact normal-set minima and the local-class window, with no external certificates.

  • At least 8,138 distinct prime factors (unconditional)

    Every composite n ≥ 2 satisfying Giuga's congruence has at least 8,138 distinct prime factors, with zero external certificate hypotheses.

  • More than 10⁴⁰⁷⁴⁷ (at least 40,748 digits, unconditional)

    Every composite n ≥ 2 satisfying Giuga's congruence satisfies 10⁴⁰⁷⁴⁷ < n, so n has at least 40,748 decimal digits.

  • Exact normal-set minima and seven-rule local ceiling window

    Normal odd prime sets with reciprocal sum above 1 have minimum size 8,135 and minimum product digits 40,733 (attained by G); adding the seven value-one local rules raises the minimum size to 8,138 and pins the minimum digits to {40,748, 40,749, 40,750} (attained at 40,750 by W_321169).

  • Every normal odd prime set with reciprocal sum > 1 has ≥ 8,135 primes
  • Every normal odd prime set with reciprocal sum > 1 has product > 10⁴⁰⁷³²
  • Product > 10⁴⁰⁷⁴⁷ when the prime count is 2 mod 4
  • Exactness of the 8,135-prime minimum
  • The seven-rule value-one local class
  • Master five-leaf normal-set bound
  • Exhaustive five-leaf partition below 17
  • Given the 8,135 bound, every counterexample has at least 8,138 prime factors

    Assume every normal set of odd primes whose reciprocals add up to more than 1 has at least 8,135 members. Then every counterexample to Giuga's conjecture has at least 8,138 different prime factors.

  • Given the 8,135 bound and the per-prefix certificates, every counterexample is larger than 10⁴⁰⁷⁴⁷

    Assume the 8,135 bound. Let F contain every normal set of odd primes below 17. Suppose that for each S in F a count K(S) of primes from 17 up is guaranteed in every normal set with prefix S whose reciprocals add up to more than 1, and that numbers μ, ν, C, a set U, pairs E and prices η are given that satisfy the refined size form's conditions with the lifted bound above 40,747·ln 10. Then every counterexample n satisfies n > 10⁴⁰⁷⁴⁷, so it has at least 40,748 digits.

  • Given the 8,135 bound, every counterexample is larger than 10³⁶⁰⁸³

    Under the same hypothesis, every counterexample n satisfies n > 10³⁶⁰⁸³, so it has at least 36,084 digits.

  • Given the 8,135 bound, a normal set whose reciprocals add up to more than 2 has at least 91,476 members

    Assume every normal set of odd primes whose reciprocals add up to more than 1 has at least 8,135 members. Then every normal set of odd primes whose reciprocals add up to more than 2 has at least 91,476 members.

  • Given the 8,135 bound, a normal set whose reciprocals add up to more than 2 has a product above 10⁴⁴⁶¹⁷⁷

    Under the same hypothesis, every normal set of odd primes whose reciprocals add up to more than 2 has a product larger than 10⁴⁴⁶¹⁷⁷.

  • Any 8,135 odd primes include one that is at least 83,341

    If Q is a set of odd primes with at least 8,135 members, some member of Q is at least 83,341.

  • There are fewer than 8,135 odd primes below 83,341
  • The sieve's bit count below 83,341 is 8,134
Short

Watch on YouTube ↗