problems / brocard

Also in this folder: compute/ · figures/ · lean/

Brocard–Ramanujan modular hunt

In general

Brocard (1876, 1885) and Ramanujan (1913) asked for the positive integers nn such that n!+1n!+1 is a square. The only known solutions are

4!+1=52,5!+1=112,7!+1=712.4!+1=5^2,\qquad 5!+1=11^2,\qquad 7!+1=71^2.

Erdős conjectured there are no others. The equation is formal-conjectures #1417 / Erdős #398; the Lean statement already lives in FormalConjectures/ErdosProblems/398.lean. Overholt showed that a weak form of abcabc implies only finitely many solutions. That is not a proof, and it is not tonight's job.

The computational handle is modular. Berndt–Galway (2000) used a quadratic-residue sieve: a candidate nn dies if some prime p>np>n has (n!+1p)=−1\bigl(\frac{n!+1}{p}\bigr)=-1. They checked n≤109n\le 10^9. Later searches advertise much larger ranges (Wikipedia cites 101510^{15}); those are not the overnight target. Textbook local obstructions also include: for a prime pp with n/2<p≤nn/2<p\le n, one has n!≡0(modp)n!\equiv 0\pmod{p} so m2≡1(modp)m^2\equiv 1\pmod{p}, hence m≡±1(modp)m\equiv\pm 1\pmod{p}. Covering systems that force a quadratic nonresidue for every large residue class of nn would eliminate infinite families.

Tonight: mine modular / covering-system obstructions beyond the textbook ones; re-run a published computational range (the Berndt–Galway method on a slice you can actually finish, with the method written down); Lean-formalize one sharp modular lemma. Do not claim the conjecture. A new Brown number is not expected and is not required.

Precise statement

A Brown pair is a pair of integers (n,m)(n,m) with n≥1n\ge 1 and n!+1=m2n!+1=m^2. The known pairs are (4,5)(4,5), (5,11)(5,11), (7,71)(7,71).

Tonight's finite targets.

  1. Modular hunt. Search for congruential obstructions to n!+1=m2n!+1=m^2 that are not the three textbook facts (n≥4⇒mn\ge 4\Rightarrow m odd; p∈(n/2,n]⇒m≡±1(modp)p\in(n/2,n]\Rightarrow m\equiv\pm 1\pmod{p}; the Berndt–Galway QR sieve for a single prime p>np>n). Covering systems, simultaneous QR conditions, or a new modulus family that kills an infinite arithmetic progression of nn all count. Write each obstruction as a lemma with a human-sized proof sketch.
  2. Re-run a published range. Re-implement the Berndt–Galway quadratic-residue sieve and run it at least through n≤104n\le 10^4 exactly, matching the three known solutions and no others. If time remains, push the same sieve as far as it goes in this run and record the bound. Do not quote 10910^9 or 101510^{15} as your bound unless you actually ran it.
  3. One Lean lemma. Formalize one sharp modular statement already believed true, with the informal skeleton written first. Suggested target (change it only if you find a sharper one):
    If n! + 1 = m^2, p prime, and n/2 < p ≤ n, then
    m ≡ 1 [MOD p] ∨ m ≡ -1 [MOD p].
    
    Build it under lean/ with Lean 4.32 + mathlib. No sorry in the main lemma.

What a solution looks like

Verified prime-offset families

Let pp be prime. There is no Brown index of either form

n=p−2orn=p−3n=p-2\quad\text{or}\quad n=p-3

when p≡3p\equiv3 or 5(mod8)5\pmod 8; in the second form take p>3p>3. Each of the four prime congruence classes supplies infinitely many excluded indices by Dirichlet's theorem. The primality condition is essential: this does not exclude whole residue classes of integers modulo 8, and it does not claim that the three known solutions are the only ones.

The proof is Wilson's theorem plus the supplementary law for the quadratic character of 2. Replay the independent Python/C checks and the Lean theorem:

problems/brocard/compute/q3/run_all.sh

Runs so far

Figures

None yet. A covering diagram or a survivor plot belongs here if the hunt produces one.