Skip to content
DAH

Legendre's conjecture: a prime between every two consecutive squares

OpenTo verify: Lean proofPosed by Adrien-Marie Legendre, 1808
AI-reviewed
On this page17 sections
Difficulty
84/100Major open
How far from a resolution. P vs NP = 100
Application value
3.5/100Theoretical
Realistic practical impact if resolved. P vs NP = 100
Leverage
24/100Local
How much other knowledge hinges on it. P vs NP = 100

Difficulty 84: one of Landau's four problems, and harder than it looks because even the Riemann Hypothesis (96) gives gaps of only √p·log p, a log factor short; the best unconditional exponent is 0.525 against the 0.5 needed. It sits just below the twin prime conjecture (87 in the calibration pass) and abc (85), and above the conditional parity-barrier gap problem (80), which at least has a precise sieve target. The unrefereed Ferreira claim does not move the grade. Application value 3.5: none beyond methods for primes in short intervals. Leverage 24: Andrica- and Brocard-type statements follow, little else.

The problem

Is there always a prime number between two consecutive perfect squares?

  1. 1Squares spread out; primes thin out
  2. 2Gaps must stay below about sqrt(p)
  3. 3Best proof only reaches p^0.525
  4. 4Even RH falls a logarithm short

The question. Between 11 and 44 lie the primes 22 and 33; between 44 and 99 lie 55 and 77; between 99 and 1616 lie 1111 and 1313. Legendre asked whether there is always at least one prime between consecutive squares n2n^2 and (n+1)2(n+1)^2. In Lean: ∀ n ≥ 1, ∃ p ∈ Set.Ioo (n ^ 2) ((n + 1) ^ 2), Nat.Prime p, where Set.Ioo a b is the open interval (a,b)(a,b).

A question about gaps. The interval (n2,(n+1)2)(n^2,(n+1)^2) has length 2n+12n+1, about 2x2\sqrt x for numbers xx near n2n^2. So the conjecture says, roughly, that the prime gap after a prime pp (the distance to the next prime) never exceeds about 2p2\sqrt p.

How big are prime gaps? The prime number theorem says primes near xx are spaced ln⁡x\ln x apart on average, which is tiny compared with x\sqrt x: near 101810^{18}, ln⁡x≈41\ln x\approx 41 while x=109\sqrt x=10^9. The largest gaps found by computer are only about (ln⁡p)2(\ln p)^2. So the conjecture looks safe numerically, and it has been checked for all n2n^2 up to 2⋅10192\cdot10^{19}.

Why it is not proved. A bound on every gap is much harder than a statement about the average. The best unconditional result (Baker, Harman and Pintz, 2001) finds a prime in every interval [x−x0.525,x][x-x^{0.525},x] for large xx, so gaps are below p0.525p^{0.525}; Legendre needs the exponent 0.50.5. Even the Riemann Hypothesis, the most famous open problem about primes, only gives gaps below a constant times p ln⁡p\sqrt p\,\ln p, too weak by a factor of ln⁡p\ln p. The methods work through the zeros of the Riemann zeta function: few zeros away from the critical line means primes are evenly spread over short intervals, and current estimates stop at the exponent 0.5250.525.

A claim to watch. A 2023 preprint by Ferreira (revised May 2026, not peer reviewed) claims that every interval (x,x+xλ](x,x+x^\lambda] with fixed λ>0\lambda>0 contains the expected number of primes for large xx. That would give Legendre for all large nn, and it goes beyond what even the Riemann Hypothesis gives, so it needs very careful checking.

How a solution is checked. A Lean proof of the declaration above, compared with the corpus statement by a checking tool. A proof for large nn only is partial progress; the remaining small nn could then be closed by a certified computation.

Go deeper

The full technical text.

For every integer n≥1n \ge 1 there is a prime pp with n2<p<(n+1)2n^2 < p < (n+1)^2.

Lean 4 statement in the Formal Conjectures corpus:

theorem legendre_conjecture :
    ∀ n ≥ 1, ∃ p ∈ Set.Ioo (n ^ 2) ((n + 1) ^ 2), Nat.Prime p
Words on this page (7)
Words on this page
perfect square
A number that is a whole number times itself, like 25.
prime gap
The distance between one prime and the next.
Riemann Hypothesis
A famous unproved statement about where the zeros of the zeta function lie.
zero-density estimate
A bound on how many zeta zeros can lie away from the critical line.
Cramér's conjecture
A guess that prime gaps are never much larger than the square of the logarithm.
exponential sum
A sum of numbers on the unit circle used to detect patterns in primes.
unrefereed preprint
A paper posted publicly that has not passed peer review.
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
    • Legendre's conjecture: a prime between every two consecutive squaresThe problem

State of the art

Known gap bounds are too weak. Baker, Harman and Pintz (2001) proved a prime exists in [x−x21/40,x][x - x^{21/40}, x] for all large xx, so gaps of size p0.525p^{0.525}; Legendre needs gaps below about 2p2\sqrt{p}, i.e. exponent 1/21/2. Under the Riemann Hypothesis Cramér showed gaps are O(plog⁡p)O(\sqrt{p}\log p), still a logarithm short. Cramér's heuristic gap size (log⁡p)2(\log p)^2 would give Legendre for large nn. Numerics: a table of maximal prime gaps confirms the conjecture up to n2=2⋅1019n^2 = 2\cdot 10^{19}. Unrefereed claim: a 2023 arXiv preprint by Luan Alberto Ferreira (revised May 2026, submitted to Annals of Mathematics, not published) claims that every interval (x,x+xλ](x, x+x^\lambda] with 0<λ<10<\lambda<1 contains asymptotically xλ/log⁡xx^\lambda/\log x primes, which would give Legendre for all sufficiently large nn (the Formal Conjectures file labels the large-nn statement as solved, citing Ferreira). It has not been confirmed by independent review; since the Riemann Hypothesis gives such asymptotics only for λ>1/2\lambda > 1/2, the claim goes beyond RH and needs especially careful checking. Even if correct, it would not settle small nn beyond the numerical range.

Realistic applications

None directly; primes in short intervals matter for the analysis of algorithms that search for primes, but nothing deployed depends on the exponent. The methods (zero-density estimates and exponential sums) are reused elsewhere in analytic number theory.

What counts as solved

A Lean proof of legendre_conjecture as stated. A proof of the eventual version alone (for all sufficiently large nn) is a genuine partial result and would be recorded as PARTIAL, with the finite range closed by computation checked in Lean.

How it gets verified

To verify: Lean proof

A formal proof checked by Lean 4 / Mathlib.

Statement: LegendreConjecture.legendre_conjecture in formal-conjectures: ∀ n ≥ 1, ∃ p ∈ Set.Ioo (n ^ 2) ((n + 1) ^ 2), Nat.Prime p. All ingredients are in Mathlib (Nat.Prime, Set.Ioo). The same file (pinned at commit e754a78, 17 October 2026) states the eventual version legendre_conjecture.ferreira_large_n (∀ᶠ n in atTop, ..., labelled solved on the strength of Ferreira's unrefereed preprint) and a conditional implication bounded_gap_legendre with a linked Lean proof by AlphaProof, which are useful stepping stones; Mathlib itself has Bertrand's postulate (NumberTheory.Bertrand) but nothing near squares. Accept a proof only if it compiles against the corpus' pinned Mathlib and a statement-fixing judge confirms the declaration is unchanged.

Claims

Where the work is

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

Progress requires stronger zero-density or exponential-sum estimates; computation is limited to checking prime gaps.

Connected problems

Progress

  1. Jul 17, 2023
    Ferreira preprint

    Claims primes in all intervals (x, x+x^λ] asymptotically, implying Legendre for large n. Unrefereed; version 4 dated 7 May 2026.

    source
  2. Jan 1, 2001
    Gaps below p^0.525

    Baker, Harman and Pintz prove primes in [x - x^(21/40), x] for large x (year only known).

    source