{
  "id": "2714",
  "ident": "NS.02714",
  "slug": "erdos-649",
  "title": "Erdős Problem 649",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Let $P(m)$ denote the greatest prime factor of $m$. Is it true that, for any two primes $p,q$,\nthere exists some integer $n$ such that $P(n)=p$ and $P(n+1)=q$?\n\nIn fact, the answer to this question as written is easily seen to be no, since there are no\nsolutions to $2^k\\equiv -1\\pmod{7}$, and hence this fails with $p=2$ and $q=7$. It is possible\nthat Erdős meant to exclude such obstructions, by amending this to 'odd primes' or 'all\nsufficiently large primes' or such.\n\nThe statement below assumes $p \\neq q$: for $p = q$ no such $n$ exists, because $p$ would divide\nboth $n$ and $n+1$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos649.erdos_649",
  "statement_lean": "theorem erdos_649 :\n    ¬ ∀ p q : ℕ, p.Prime → q.Prime → p ≠ q →\n      ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 649\n\n*References:*\n- [erdosproblems.com/649](https://www.erdosproblems.com/649)\n- [Ma35] Mahler, Kurt, *Über den grössten Primteiler spezieller Polynome zweiten Grades*. Archiv\n  für math. og naturvid (1935).\n- [Ro64b] Rotkiewicz, André, *Sur les nombres naturels $n$ et $k$ tels que les nombres $n$ et $nk$\n  sont à la fois pseudopremiers*. Atti Accad. Naz. Lincei Rend. Cl. Sci. Fis. Mat. Nat. (8)\n  (1964), 816-818.\n-/\n\n@[expose] public section\n\nnamespace Erdos649\n\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $P(m)$ denote the greatest prime factor of $m$. Is it true that, for any two primes $p,q$,\nthere exists some integer $n$ such that $P(n)=p$ and $P(n+1)=q$?\n\nIn fact, the answer to this question as written is easily seen to be no, since there are no\nsolutions to $2^k\\equiv -1\\pmod{7}$, and hence this fails with $p=2$ and $q=7$. It is possible\nthat Erdős meant to exclude such obstructions, by amending this to 'odd primes' or 'all\nsufficiently large primes' or such.\n\nThe statement below assumes $p \\neq q$: for $p = q$ no such $n$ exists, because $p$ would divide\nboth $n$ and $n+1$.\n-/\n@[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\"]\ntheorem erdos_649 :\n    ¬ ∀ p q : ℕ, p.Prime → q.Prime → p ≠ q →\n      ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nThe number of solutions is finite for any fixed $p,q$ since the largest prime factor of $n(n+1)$\ntends to $\\infty$ (Mahler [Ma35] showed that this is $\\gg \\log\\log n$, see\n[368](https://www.erdosproblems.com/368)).\n-/\n@[category research solved, AMS 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L97\"]\ntheorem erdos_649.variants.finite (p q : ℕ) :\n    {n : ℕ | n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Finite := by\n  sorry\n\n/--\nIn fact, the answer to this question as written is easily seen to be no, since there are no\nsolutions to $2^k\\equiv -1\\pmod{7}$, and hence this fails with $p=2$ and $q=7$.\n-/\n@[category textbook, AMS 11]\ntheorem erdos_649.variants.no_solution_two_seven :\n    ¬ ∃ n : ℕ, n.maxPrimeFac = 2 ∧ (n + 1).maxPrimeFac = 7 := by\n  rintro ⟨n, hn, hn'⟩\n  have h1n : 1 < n := by\n    have := (Nat.one_lt_maxPrimeFac_iff n).mp (by omega)\n    omega\n  -- Since `2` is the greatest prime factor of `n`, it is the only one, so `n` is a power of `2`.\n  obtain ⟨k, hpow⟩ : ∃ k, n = 2 ^ k :=\n    ⟨_, Nat.eq_prime_pow_of_unique_prime_dvd (by omega)\n      (fun {q} hq hqd ↦\n        le_antisymm (hn ▸ Nat.le_maxPrimeFac (by omega) hq hqd) hq.two_le)⟩\n  -- On the other hand `7` divides `n + 1`, i.e. `2 ^ k ≡ -1 (mod 7)`.\n  have h7 : 7 ∣ n + 1 := hn' ▸ Nat.maxPrimeFac_dvd\n  -- This is impossible: `2 ^ k` is congruent to `1`, `2` or `4` modulo `7`, never to `6`.\n  have hmod : 2 ^ k % 7 = 2 ^ (k % 3) % 7 := by\n    conv_lhs => rw [← Nat.div_add_mod k 3, pow_add, pow_mul]\n    rw [Nat.mul_mod, Nat.pow_mod]\n    norm_num\n  have hk3 : k % 3 < 3 := Nat.mod_lt _ (by norm_num)\n  interval_cases h : k % 3 <;> omega\n\nset_option linter.style.formal_proof_palomar false in\n/--\nEven with such amendments, this problem is false in a strong sense: Alan Tong has provided the\nfollowing elegant elementary proof that, for any given prime $p$, there are infinitely many\nprimes $q$ such that this statement is false: let $m$ be the product of all primes $\\leq p$, and\nchoose a prime $q$ congruent to $-1$ modulo $4m$. If $p$ is the greatest prime divisor of $n$\nthen, using quadratic reciprocity, every prime divisor of $n$ is a quadratic residue modulo $q$,\nand hence $n$ is a quadratic residue modulo $q$. On the other hand, since $q\\equiv 3\\pmod{4}$ we\nknow that $-1$ is not a quadratic residue modulo $q$, and hence $n\\not\\equiv -1\\pmod{q}$, so it\nis impossible for $q\\mid n+1$.\n-/\n@[category research solved, AMS 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L374\"]\ntheorem erdos_649.variants.tong (p : ℕ) (hp : p.Prime) :\n    {q : ℕ |\n      q.Prime ∧ ¬ ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Infinite := by\n  sorry\n\n/--\nTong asks whether, for any given odd prime $q$, there are infinitely many primes $p$ such that\nthere is no integer $n$ with $P(n)=p$ and $P(n+1)=q$.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_649.variants.tong_question :\n    ∀ q : ℕ, q.Prime → Odd q →\n      {p : ℕ |\n        p.Prime ∧ ¬ ∃ n : ℕ, n.maxPrimeFac = p ∧ (n + 1).maxPrimeFac = q}.Infinite := by\n  sorry\n\n/--\nSampaio independently observed that the answer to Erdős' original problem is no if one of the\nprimes can be $2$ - for example this is false with $p=19$ and $q=2$, since if $n+1=2^k$ and\n$19\\mid n$ then (since $2$ is a primitive root modulo $19$) we must have $18\\mid k$, and hence\n$73\\mid 2^{18}-1\\mid n$.\n-/\n@[category textbook, AMS 11]\ntheorem erdos_649.variants.sampaio :\n    ¬ ∃ n : ℕ, n.maxPrimeFac = 19 ∧ (n + 1).maxPrimeFac = 2 := by\n  rintro ⟨n, hn, hn'⟩\n  have hn0 : n ≠ 0 := by\n    rintro rfl\n    simp at hn\n  -- Since `2` is the greatest prime factor of `n + 1`, it is the only one, so `n + 1` is a power\n  -- of `2`.\n  obtain ⟨k, hpow⟩ : ∃ k, n + 1 = 2 ^ k :=\n    ⟨_, Nat.eq_prime_pow_of_unique_prime_dvd (by omega)\n      (fun {q} hq hqd ↦\n        le_antisymm (hn' ▸ Nat.le_maxPrimeFac (by omega) hq hqd) hq.two_le)⟩\n  -- On the other hand `19` divides `n`, i.e. `2 ^ k ≡ 1 (mod 19)`.\n  have h19 : 19 ∣ n := hn ▸ Nat.maxPrimeFac_dvd\n  -- Modulo `2 ^ 18 - 1`, which both `19` and `73` divide, `2 ^ k` depends only on `k % 18`.\n  have hmod : 2 ^ k % (2 ^ 18 - 1) = 2 ^ (k % 18) % (2 ^ 18 - 1) := by\n    conv_lhs => rw [← Nat.div_add_mod k 18, pow_add, pow_mul]\n    rw [Nat.mul_mod, Nat.pow_mod]\n    norm_num\n  -- As `2` is a primitive root modulo `19`, this forces `18 ∣ k`, and then `73 ∣ 2 ^ 18 - 1 ∣ n`.\n  have h73 : 73 ∣ n := by\n    have hk : k % 18 < 18 := Nat.mod_lt _ (by norm_num)\n    interval_cases h : k % 18 <;> omega\n  -- But `73` is a prime factor of `n` larger than `19`.\n  have := hn ▸ Nat.le_maxPrimeFac hn0 (by norm_num) h73\n  omega\n\n/--\nProblem 6 in the 12th Romanian Master of Mathematics Competitions in 2020 was to prove that there\nexist infinitely many odd primes $p$ such that, for every $n$, $P(n)P(n+1)\\neq 2p$.\n-/\n@[category textbook, AMS 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos649.lean#L1090\"]\ntheorem erdos_649.variants.rmm_2020 :\n    {p : ℕ | p.Prime ∧ Odd p ∧\n      ∀ n : ℕ, n.maxPrimeFac * (n + 1).maxPrimeFac ≠ 2 * p}.Infinite := by\n  sorry\n\nend Erdos649\n",
  "statement_hash": "56cb42061685e72f30d8684036b01652aa66b8b027668fab5f4dd7b3ee2f1ed9",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}