Skip to content
DARC
■ Change #98 · wiki.edited

The Agoh–Giuga conjecture: a congruence that detects primes: Normalize Markdown to canonical form

by DARC wiki2026-10-22 20:31:09 UTCOpen the page →
body
Giuga's form: an integer $n \ge 2$ is prime if and only if
− $$1^{n-1} + 2^{n-1} + \cdots + (n-1)^{n-1} \equiv -1 \pmod n.$$
+ $1^{n-1} + 2^{n-1} + \cdots + (n-1)^{n-1} \equiv -1 \pmod n.$
Agoh's equivalent form uses Bernoulli numbers: $n$ is prime iff $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:
```lean
def AgohGiugaSum : Prop := ∀ p ≥ 2, p.Prime ↔
p ∣ 1 + ∑ i ∈ Finset.Ioo 0 p, i^(p - 1 : ℕ)
theorem agoh_giuga.variants.giuga : AgohGiugaSum
```
explainer.student
**Modular arithmetic.** "$a\equiv b \pmod n$" means that $a$ and $b$ leave the same remainder on division by $n$ (in Python, `a % n == b % n`). "$\equiv -1 \pmod n$" means the remainder is $n-1$.
**Fermat's little theorem.** If $p$ is prime and does not divide $a$, then $a^{p-1}\equiv1\pmod p$. Try $p=5$: $2^4=16$, $3^4=81$ and $4^4=256$ all leave remainder 1.
− **Giuga's test.** Add up $1^{n-1}+2^{n-1}+\cdots+(n-1)^{n-1}$. If $n=p$ is prime, each of the $p-1$ terms is $\equiv1$, so the sum is $\equiv p-1\equiv-1\pmod p$. Giuga conjectured in 1950 that the converse also holds: if the sum is $\equiv-1\pmod n$, then $n$ is prime. For $n=6$ the sum is $1+32+243+1024+3125=4425$, and $4425+1=4426$ is not a multiple of 6, so 6 fails, as a composite should. For $n=7$ the sum of sixth powers is $67171$, and $67172=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 $1^2+2^2+\cdots+m^2$.
+ **Giuga's test.** Add up $1^{n-1}+2^{n-1}+\cdots+(n-1)^{n-1}$. If $n=p$ is prime, each of the $p-1$ terms is $\equiv1$, so the sum is $\equiv p-1\equiv-1\pmod p$. Giuga conjectured in 1950 that the converse also holds: if the sum is $\equiv-1\pmod n$, then $n$ is prime. For $n=6$ the sum is $1+32+243+1024+3125=4425$, and $4425+1=4426$ is not a multiple of 6, so 6 fails, as a composite should. For $n=7$ the sum of sixth powers is $67171$, and $67172=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 $1^2+2^2+\cdots+m^2$.
**In Lean.** For every $p\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 $p$ dividing $n$, $p$ divides $n/p-1$), and must have at least 13,800 digits. An unrefereed Italian working paper by Sorini (2001) is cited for about $10^{36067}$. Thirteen Giuga numbers are known; the smallest is $30=2\cdot3\cdot5$ (check: $30/2-1=14$, $30/3-1=9$, $30/5-1=5$). All known ones are even, while Carmichael numbers are always odd, so none of them is a counterexample.
+ **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 $p$ dividing $n$, $p$ divides $n/p-1$), and must have at least 13,800 digits. An unrefereed Italian working paper by Sorini (2001) is cited for about $10^{36067}$. Thirteen Giuga numbers are known; the smallest is $30=2\cdot3\cdot5$ (check: $30/2-1=14$, $30/3-1=9$, $30/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 $n$ that Lean can verify with fast modular exponentiation; a proof must cover every $n\ge2$.
hash 33567b796371bed6546928eadb5985dedb63006d81e8644f557f8a2b039ba1b4
previous c60c78a01674288ede9d6f602ff01485d8b31e1ec2646bb83af1c764e3f1e495