Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

[Imported from formal-conjectures on 23 Nov 2026]

Title:Erdős Problem 649

Source:Erdős Problems
Known result Solved on paper; nobody has proved it in Lean here yet. First verified proof: +10 points.
Statement:reviewed
Statement:

Let P(m)P(m) denote the greatest prime factor of mm. Is it true that, for any two primes p,qp,q, there exists some integer nn such that P(n)=pP(n)=p and P(n+1)=qP(n+1)=q?

In fact, the answer to this question as written is easily seen to be no, since there are no solutions to 2k≡−1(mod7)2^k\equiv -1\pmod{7}, and hence this fails with p=2p=2 and q=7q=7. It is possible that Erdős meant to exclude such obstructions, by amending this to 'odd primes' or 'all sufficiently large primes' or such.

The statement below assumes p≠qp \neq q: for p=qp = q no such nn exists, because pp would divide both nn and n+1n+1.

Subjects:Number Theory (math.NT)
MSC classes:11
Tags:question, formal_proof
Cite as:NS.02714 [math.NT] · NS.02714v1 for this version
Declaration:Erdos649.erdos_649
Verification:Lean kernel (formal proof)
Points:first verified proof or disproof: 10, later ones: 2; accepted critique: up to 60
Statement hash:56cb42061685e72f30d8684036b01652aa66b8b027668fab5f4dd7b3ee2f1ed9
Toolchain:leanprover/lean4:v4.33.1
Licence:Apache-2.0 · google-deepmind/formal-conjectures contributors
Upstream:FormalConjectures/ErdosProblems/649.lean

Formal statement

theorem erdos_649 :
    ¬ ∀ p q : ℕ, p.Prime → q.Prime → p ≠ q →
      ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q
Show the full Challenge.lean (165 lines) — definitions included
module

public import FormalConjecturesUtil

/-!
# Erdős Problem 649

*References:*
- [erdosproblems.com/649](https://www.erdosproblems.com/649)
- [Ma35] Mahler, Kurt, *Über den grössten Primteiler spezieller Polynome zweiten Grades*. Archiv
  für math. og naturvid (1935).
- [Ro64b] Rotkiewicz, André, *Sur les nombres naturels $n$ et $k$ tels que les nombres $n$ et $nk$
  sont à la fois pseudopremiers*. Atti Accad. Naz. Lincei Rend. Cl. Sci. Fis. Mat. Nat. (8)
  (1964), 816-818.
-/

@[expose] public section

namespace Erdos649

set_option linter.style.formal_proof_palomar false in
/--
Let $P(m)$ denote the greatest prime factor of $m$. Is it true that, for any two primes $p,q$,
there exists some integer $n$ such that $P(n)=p$ and $P(n+1)=q$?

In fact, the answer to this question as written is easily seen to be no, since there are no
solutions to $2^k\equiv -1\pmod{7}$, and hence this fails with $p=2$ and $q=7$. It is possible
that Erdős meant to exclude such obstructions, by amending this to 'odd primes' or 'all
sufficiently large primes' or such.

The statement below assumes $p \neq q$: for $p = q$ no such $n$ exists, because $p$ would divide
both $n$ and $n+1$.
-/
@[category research solved, question, AMS 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L488"]
theorem erdos_649 :
    ¬ ∀ p q : ℕ, p.Prime → q.Prime → p ≠ q →
      ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q := by
  sorry

set_option linter.style.formal_proof_palomar false in
/--
The number of solutions is finite for any fixed $p,q$ since the largest prime factor of $n(n+1)$
tends to $\infty$ (Mahler [Ma35] showed that this is $\gg \log\log n$, see
[368](https://www.erdosproblems.com/368)).
-/
@[category research solved, AMS 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L97"]
theorem erdos_649.variants.finite (p q : ℕ) :
    {n : ℕ | n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Finite := by
  sorry

/--
In fact, the answer to this question as written is easily seen to be no, since there are no
solutions to $2^k\equiv -1\pmod{7}$, and hence this fails with $p=2$ and $q=7$.
-/
@[category textbook, AMS 11]
theorem erdos_649.variants.no_solution_two_seven :
    ¬ ∃ n : ℕ, n.maxPrimeFac = 2 ∧ (n + 1).maxPrimeFac = 7 := by
  rintro ⟨n, hn, hn'⟩
  have h1n : 1 < n := by
    have := (Nat.one_lt_maxPrimeFac_iff n).mp (by omega)
    omega
  -- Since `2` is the greatest prime factor of `n`, it is the only one, so `n` is a power of `2`.
  obtain ⟨k, hpow⟩ : ∃ k, n = 2 ^ k :=
    ⟨_, Nat.eq_prime_pow_of_unique_prime_dvd (by omega)
      (fun {q} hq hqd ↦
        le_antisymm (hn ▸ Nat.le_maxPrimeFac (by omega) hq hqd) hq.two_le)⟩
  -- On the other hand `7` divides `n + 1`, i.e. `2 ^ k ≡ -1 (mod 7)`.
  have h7 : 7 ∣ n + 1 := hn' ▸ Nat.maxPrimeFac_dvd
  -- This is impossible: `2 ^ k` is congruent to `1`, `2` or `4` modulo `7`, never to `6`.
  have hmod : 2 ^ k % 7 = 2 ^ (k % 3) % 7 := by
    conv_lhs => rw [← Nat.div_add_mod k 3, pow_add, pow_mul]
    rw [Nat.mul_mod, Nat.pow_mod]
    norm_num
  have hk3 : k % 3 < 3 := Nat.mod_lt _ (by norm_num)
  interval_cases h : k % 3 <;> omega

set_option linter.style.formal_proof_palomar false in
/--
Even with such amendments, this problem is false in a strong sense: Alan Tong has provided the
following elegant elementary proof that, for any given prime $p$, there are infinitely many
primes $q$ such that this statement is false: let $m$ be the product of all primes $\leq p$, and
choose a prime $q$ congruent to $-1$ modulo $4m$. If $p$ is the greatest prime divisor of $n$
then, using quadratic reciprocity, every prime divisor of $n$ is a quadratic residue modulo $q$,
and hence $n$ is a quadratic residue modulo $q$. On the other hand, since $q\equiv 3\pmod{4}$ we
know that $-1$ is not a quadratic residue modulo $q$, and hence $n\not\equiv -1\pmod{q}$, so it
is impossible for $q\mid n+1$.
-/
@[category research solved, AMS 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L374"]
theorem erdos_649.variants.tong (p : ℕ) (hp : p.Prime) :
    {q : ℕ |
      q.Prime ∧ ¬ ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Infinite := by
  sorry

/--
Tong asks whether, for any given odd prime $q$, there are infinitely many primes $p$ such that
there is no integer $n$ with $P(n)=p$ and $P(n+1)=q$.
-/
@[category research open, question, AMS 11]
theorem erdos_649.variants.tong_question :
    ∀ q : ℕ, q.Prime → Odd q →
      {p : ℕ |
        p.Prime ∧ ¬ ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Infinite := by
  sorry

/--
Sampaio independently observed that the answer to Erdős' original problem is no if one of the
primes can be $2$ - for example this is false with $p=19$ and $q=2$, since if $n+1=2^k$ and
$19\mid n$ then (since $2$ is a primitive root modulo $19$) we must have $18\mid k$, and hence
$73\mid 2^{18}-1\mid n$.
-/
@[category textbook, AMS 11]
theorem erdos_649.variants.sampaio :
    ¬ ∃ n : ℕ, n.maxPrimeFac = 19 ∧ (n + 1).maxPrimeFac = 2 := by
  rintro ⟨n, hn, hn'⟩
  have hn0 : n ≠ 0 := by
    rintro rfl
    simp at hn
  -- Since `2` is the greatest prime factor of `n + 1`, it is the only one, so `n + 1` is a power
  -- of `2`.
  obtain ⟨k, hpow⟩ : ∃ k, n + 1 = 2 ^ k :=
    ⟨_, Nat.eq_prime_pow_of_unique_prime_dvd (by omega)
      (fun {q} hq hqd ↦
        le_antisymm (hn' ▸ Nat.le_maxPrimeFac (by omega) hq hqd) hq.two_le)⟩
  -- On the other hand `19` divides `n`, i.e. `2 ^ k ≡ 1 (mod 19)`.
  have h19 : 19 ∣ n := hn ▸ Nat.maxPrimeFac_dvd
  -- Modulo `2 ^ 18 - 1`, which both `19` and `73` divide, `2 ^ k` depends only on `k % 18`.
  have hmod : 2 ^ k % (2 ^ 18 - 1) = 2 ^ (k % 18) % (2 ^ 18 - 1) := by
    conv_lhs => rw [← Nat.div_add_mod k 18, pow_add, pow_mul]
    rw [Nat.mul_mod, Nat.pow_mod]
    norm_num
  -- As `2` is a primitive root modulo `19`, this forces `18 ∣ k`, and then `73 ∣ 2 ^ 18 - 1 ∣ n`.
  have h73 : 73 ∣ n := by
    have hk : k % 18 < 18 := Nat.mod_lt _ (by norm_num)
    interval_cases h : k % 18 <;> omega
  -- But `73` is a prime factor of `n` larger than `19`.
  have := hn ▸ Nat.le_maxPrimeFac hn0 (by norm_num) h73
  omega

/--
Problem 6 in the 12th Romanian Master of Mathematics Competitions in 2020 was to prove that there
exist infinitely many odd primes $p$ such that, for every $n$, $P(n)P(n+1)\neq 2p$.
-/
@[category textbook, AMS 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L1090"]
theorem erdos_649.variants.rmm_2020 :
    {p : ℕ | p.Prime ∧ Odd p ∧
      ∀ n : ℕ, n.maxPrimeFac * (n + 1).maxPrimeFac ≠ 2 * p}.Infinite := by
  sorry

end Erdos649

To prove it: keep every definition of Challenge.lean unchanged and prove Erdos649.erdos_649 with the same type — no sorry in what it depends on, no new axioms. To disprove it: add theorem not_erdos_649 : ¬ (…) in the same namespace, stating exactly the negation, and submit it as a disproof.

nosorry fetch erdos-649
nosorry submit erdos-649 nosorry/erdos-649/Solution.lean --wait

Formal variants

Other formal statements attached to the same informal problem (weaker, stronger, special cases). Each is scored separately.

Contributions

No contributions yet — be the first. Submit a proof or a finding.

Research in progress

People working on this problem share their repository and a summary of what they have tried — dead ends included. Read these before starting, build on them, and credit them in prior work when you submit.

Nobody has shared research on this problem yet.

Sign in to share your research.

Statement review

Is the formal statement faithful to the problem? Too weak, too strong, already solved in the literature? An accepted critique creates a new statement version; proofs of the previous version are re-checked and their points adjusted.

Sign in to open a critique.