Skip to content
DAH

The Agoh–Giuga conjecture: a congruence that detects primes

OpenTo verify: Lean proofPosed by Giuseppe Giuga, 1950; Takashi Agoh, 1995 (Bernoulli form)
AI-reviewed
On this page18 sections
Difficulty
69.5/100Research-grade
How far from a resolution. P vs NP = 100
Application value
3.2/100Theoretical
Realistic practical impact if resolved. P vs NP = 100
Leverage
8/100Isolated
How much other knowledge hinges on it. P vs NP = 100

Difficulty 69.5: open since 1950, with a counterexample forced to be both a Carmichael and a Giuga number of at least 13,800 digits, but no argument that the two conditions are incompatible; a sibling of Lehmer's problem (72), slightly lower because the structure of a counterexample is sharper. Application value 3.2: a primality characterization whose false positives are the Carmichael numbers that practical tests already handle. Leverage 8: isolated.

The problem

Does adding the (n−1)-th powers of 1 through n−1 and getting −1 mod n happen only for primes?

  1. 1Primes pass the power-sum test
  2. 2Does any composite number pass?
  3. 3A passer would need 13,800+ digits
  4. 4None known, none excluded

Modular arithmetic. "a≡b(modn)a\equiv b \pmod n" means that aa and bb leave the same remainder on division by nn (in Python, a % n == b % n). "≡−1(modn)\equiv -1 \pmod n" means the remainder is n−1n-1.

Fermat's little theorem. If pp is prime and does not divide aa, then ap−1≡1(modp)a^{p-1}\equiv1\pmod p. Try p=5p=5: 24=162^4=16, 34=813^4=81 and 44=2564^4=256 all leave remainder 1.

Giuga's test. Add up 1n−1+2n−1+⋯+(n−1)n−11^{n-1}+2^{n-1}+\cdots+(n-1)^{n-1}. If n=pn=p is prime, each of the p−1p-1 terms is ≡1\equiv1, so the sum is ≡p−1≡−1(modp)\equiv p-1\equiv-1\pmod p. Giuga conjectured in 1950 that the converse also holds: if the sum is ≡−1(modn)\equiv-1\pmod n, then nn is prime. For n=6n=6 the sum is 1+32+243+1024+3125=44251+32+243+1024+3125=4425, and 4425+1=44264425+1=4426 is not a multiple of 6, so 6 fails, as a composite should. For n=7n=7 the sum of sixth powers is 6717167171, and 67172=7⋅959667172=7\cdot9596, so 7 passes. Agoh (1995) gave an equivalent form using Bernoulli numbers, the rational numbers that appear in formulas for sums of powers such as 12+22+⋯+m21^2+2^2+\cdots+m^2.

In Lean. For every p≥2p\ge2: p.Prime ↔ p ∣ 1 + ∑ i ∈ Finset.Ioo 0 p, i^(p - 1). The corpus also states the Bernoulli form and the equivalence of the two; the equivalence is labelled as known, but its Lean proof is still left blank.

What a counterexample would need. Borwein, Borwein, Borwein and Girgensohn (1996) proved that a composite passing the test must be a Carmichael number (a composite that passes Fermat's test for every base coprime to it) and a Giuga number (for every prime pp dividing nn, pp divides n/p−1n/p-1), and must have at least 13,800 digits. An unrefereed Italian working paper by Sorini (2001) is cited for about 103606710^{36067}. Thirteen Giuga numbers are known; the smallest is 30=2⋅3⋅530=2\cdot3\cdot5 (check: 30/2−1=1430/2-1=14, 30/3−1=930/3-1=9, 30/5−1=530/5-1=5). All known ones are even, while Carmichael numbers are always odd, so none of them is a counterexample.

Why it is stuck. Each condition is very restrictive, but nobody has shown that a number can never satisfy both at once.

How it is checked. A counterexample is one number plus a computation of the sum modulo nn that Lean can verify with fast modular exponentiation; a proof must cover every n≥2n\ge2.

Go deeper

The full technical text.

Giuga's form: an integer n≥2n \ge 2 is prime if and only if 1n−1+2n−1+⋯+(n−1)n−1≡−1(modn).1^{n-1} + 2^{n-1} + \cdots + (n-1)^{n-1} \equiv -1 \pmod n. Agoh's equivalent form uses Bernoulli numbers: nn is prime iff nBn−1≡−1(modn)nB_{n-1} \equiv -1 \pmod n. The forward direction (primes satisfy it) follows from Fermat's little theorem; the open part is that no composite satisfies it.

Lean 4 statement (Giuga's formulation) in the Formal Conjectures corpus:

def AgohGiugaSum : Prop := ∀ p ≥ 2, p.Prime ↔
  p ∣ 1 + ∑ i ∈ Finset.Ioo 0 p, i^(p - 1 : ℕ)

theorem agoh_giuga.variants.giuga : AgohGiugaSum
Words on this page (6)
Words on this page
Fermat's little theorem
For a prime p, raising a number not divisible by p to the power p minus 1 leaves remainder 1 modulo p.
Bernoulli numbers
A sequence of rational numbers that appear in formulas for power sums.
Giuga number
A composite number n where every prime factor p divides n over p minus 1.
Carmichael number
A composite number that passes the Fermat primality test for all bases.
congruence
Two numbers have the same remainder after division by n.
Lehmer's totient problem
A related unsolved question about a congruence that detects primes.
New to this? Read first (2)
New to this? Read first

Path to understanding

foundations → problem

The research entries this problem rests on, in the order to read them. Each links to its explainer.

  1. Start with
  2. Step 2
  3. Step 3
  4. Then
    • The Agoh–Giuga conjecture: a congruence that detects primesThe problem

State of the art

Borwein, Borwein, Borwein and Girgensohn (1996) showed a composite counterexample must be both a Carmichael number and a Giuga number, and would have at least 13,800 digits. Sorini (2001), an Italian working paper whose title describes a heuristic method (Quaderni di Economia, Matematica e Statistica, Urbino), is cited for raising this to about 103606710^{36067}; it is not refereed, so the 13,800-digit bound is the safe one to quote. Giuga numbers satisfy p∣(n/p−1)p \mid (n/p - 1) for every prime p∣np \mid n; thirteen are known (the first is 3030, the twelfth has 34 digits), all even, and an odd Giuga number would need at least 14 prime factors. The corpus states the equivalence of the two formulations as a known result (agoh_giuga.variants.equivalence), but its Lean proof is still left as sorry.

Realistic applications

None directly. It belongs to the family of primality characterizations whose false positives (Carmichael-type numbers) are exactly what cryptographic primality tests are designed to avoid.

What counts as solved

A Lean proof of agoh_giuga.variants.giuga (the Bernoulli form agoh_giuga would then follow once the corpus' equivalence statement is also proved in Lean), or an explicit composite nn with n∣1+∑i<nin−1n \mid 1 + \sum_{i<n} i^{n-1}, which the kernel can check.

How it gets verified

To verify: Lean proof

A formal proof checked by Lean 4 / Mathlib.

Statement: AgohGiuga.agoh_giuga.variants.giuga (and agoh_giuga for the Bernoulli form, using Mathlib's bernoulli') in formal-conjectures. Mathlib supplies Nat.Prime, Finset.Ioo and Bernoulli numbers (NumberTheory.Bernoulli); the Giuga-number definitions are in the corpus file itself, which also states the equivalence of the two formulations but leaves its proof as sorry, so a proof of one form does not yet give the other in Lean. A counterexample is a single composite nn that Lean can check by evaluating the power sum modulo nn (kernel-checkable with fast modular exponentiation lemmas). A proof must cover all n≥2n \ge 2. Judge with Comparator against the pinned statement.

Claims

No claimed results on this problem.

Where the work is

Theory
72%
New mathematical or conceptual ideas
Engineering
0%
Building instruments, chips, systems, software, formal proofs
Compute
28%
Raw computation, search, simulation
Empirical
0%
Observation, experiment, data collection

The structure theory (Carmichael and Giuga conditions) is the main content; search effort has already pushed the size bound far.

Connected problems

Progress

  1. Jan 1, 1996
    13,800-digit lower bound

    Borwein, Borwein, Borwein and Girgensohn show a counterexample is Carmichael and Giuga with at least 13,800 digits (year only known).

    source
  2. Jan 1, 1950
    Giuga's conjecture

    Giuga proposes the power-sum characterization of primes (Istituto Lombardo Rendiconti 14).

    source