{
  "id": "2016",
  "ident": "NS.02016",
  "slug": "erdos-405",
  "title": "Erdős Problem 405",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Let $p$ be an odd prime. Is it true that the equation $(p-1)!+a^{p-1}=p^k$ has only finitely many\nsolutions?\n\nOriginally proposed by Erdős and Graham [ErGr80].\nBrindza and Erdős [BrEr91] proved that there are finitely many such solutions.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos405.erdos_405",
  "statement_lean": "theorem erdos_405 :\n    Set.Finite { x : ℕ × ℕ × ℕ | let (a, k, p) := x; p.Prime ∧ Odd p ∧\n      Nat.factorial (p - 1) + a ^ (p - 1) = p ^ k}",
  "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-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 405\n\n*References:*\n- [erdosproblems.com/405](https://www.erdosproblems.com/405)\n- [ErGr80] Erdős, P. and Graham, R., Old and new problems and results in combinatorial number\ntheory. Monographies de L'Enseignement Mathematique (1980)\n- [BrEr91] Brindza, B. and Erdős, P., On some {D}iophantine problems involving powers and\nfactorials. J. Austral. Math. Soc. Ser. A (1991), 1--7.\n- [YuLi96] Yu, Kunrui and Liu, Dehua, A complete resolution of a problem of {E}rdős and {G}raham.\nRocky Mountain J. Math. (1996), 1235--1244.\n-/\n\n@[expose] public section\n\nopen scoped Nat\n\nnamespace Erdos405\n\n/--\nLet $p$ be an odd prime. Is it true that the equation $(p-1)!+a^{p-1}=p^k$ has only finitely many\nsolutions?\n\nOriginally proposed by Erdős and Graham [ErGr80].\nBrindza and Erdős [BrEr91] proved that there are finitely many such solutions.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_405 :\n    Set.Finite { x : ℕ × ℕ × ℕ | let (a, k, p) := x; p.Prime ∧ Odd p ∧\n      Nat.factorial (p - 1) + a ^ (p - 1) = p ^ k} := by\n  sorry\n\n/--\nErdős and Graham [ErGr80] ask this allowing $p=2$, but this is presumably an oversight, since clearly\nthere are infinitely many solutions when $p=2$.\n\nObserve that this creates $1! + a = 2^k$. For all $k$, fix $a = 2^k - 1$.\n-/\n@[category textbook, AMS 11]\ntheorem erdos_405.variants.nonodd_p :\n    Set.Infinite { x : ℕ × ℕ × ℕ | let (a, k, p) := x; p.Prime ∧\n      Nat.factorial (p - 1) + a ^ (p - 1) = p ^ k} := by\n  -- Provide the infinite family of solutions\n  apply Set.infinite_of_injective_forall_mem (f := fun k ↦ (2^k - 1, k, 2))\n  · -- 1. Prove the function is injective\n    intro x y h\n    -- Simplify the tuple equality to individual components\n    simp only [Prod.mk.injEq] at h\n    -- The second component equality is exactly x = y\n    exact h.2.1\n  · -- 2. Prove all generated tuples belong to the set\n    intro k\n    simp only [Set.mem_ofPred_eq]\n    -- Split into proving p is prime and the equation holds\n    refine ⟨Nat.prime_two, ?_⟩\n    -- Since p = 2, 2 - 1 = 1, so the equation simplifies definitionally\n    change 1 + (2^k - 1)^1 = 2^k\n    rw [pow_one]\n    -- Prove 2^k is strictly positive so that (2^k - 1) doesn't underflow in Nat\n    have h : 0 < 2^k := by positivity\n    -- omega handles the Presburger arithmetic\n    omega\n\n/--\nYu and Liu [YuLi96] showed that the only solutions to $(p-1)! + a^(p-1) = p^k$\nfor an odd prime p are:\n$$\n2! + 1^2 = 3\\\\\n2! + 5^2 = 3^3\\\\\n4! + 1^4 = 5^2\n$$\n-/\n@[category research solved, AMS 11]\ntheorem erdos_405.variants.yu_liu :\n    { x : ℕ × ℕ × ℕ | let (a, k, p) := x; p.Prime ∧ Odd p ∧\n      Nat.factorial (p - 1) + a ^ (p - 1) = p ^ k } =\n    {(1, 1, 3), (5, 3, 3), (1, 2, 5)} := by\n  sorry\n\nend Erdos405\n",
  "statement_hash": "424c14f69df83f3f4344fa122403fbb8e5e3ff0d4863dc8bfdfb8b54668539a4",
  "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."
}