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 399

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:

Is it true that there are no solutions to n! = x^k ± y^k with x,y,n ∈ ℕ, x*y > 1, and k > 2?

The answer is no: Jonas Barfield found the counterexample 10! = 48^4 - 36^4 (equivalently, 10! + 36^4 = 48^4).

This is discussed in problem D2 of Guy's collection [Gu04].

This was formalized in Lean by Lu using Codex.

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

Formal statement

theorem erdos_399 :
    ∃ (n x y k : ℕ), 1 < x * y ∧ 2 < k ∧ (n ! = x ^ k + y ^ k ∨ n ! + y ^ k = x ^ k)
Show the full Challenge.lean (136 lines) — definitions included
module

public import FormalConjecturesUtil

/-!
# Erdős Problem 399

Is it true that there are no solutions to $n! = x^k \pm y^k$ with $x,y,n \in \mathbb{N}$,
with $xy > 1$ and $k > 2$?

*References:*
 - [erdosproblems.com/399](https://www.erdosproblems.com/399)
- [Br32] Breusch, Robert, Zur Verallgemeinerung des Bertrandschen Postulates, da\ss zwischen $x$
  und 2 $x$ stets Primzahlen liegen. Math. Z. (1932), 505--526.
- [ErOb37] Erdős, P. and Obláth, R., \"Über diophantische Gleichungen der Form $n!=x^p+y^p$ und
  $n!\pm m!=x^p$. Acta Litt. ac Sci. Reg. Univ. Hung. Fr.-Jos., Sect. Sci. Math. (1937), 241-255.
- [Gu04] Guy, Richard K., Unsolved problems in number theory. (2004), xviii+437.
- [PoSh73] Pollack, Richard M. and Shapiro, Harold N., The next to last case of a factorial
  diophantine equation. Comm. Pure Appl. Math. (1973), 313-325.
-/

@[expose] public section

open Nat

namespace Erdos399

/--
Is it true that there are no solutions to `n! = x^k ± y^k` with `x,y,n ∈ ℕ`, `x*y > 1`, and
`k > 2`?

The answer is no: Jonas Barfield found the counterexample `10! = 48^4 - 36^4` (equivalently,
`10! + 36^4 = 48^4`).

This is discussed in problem D2 of Guy's collection [Gu04].

This was formalized in Lean by Lu using Codex.
-/
@[category research solved, question, AMS 11]
theorem erdos_399 :
    ∃ (n x y k : ℕ), 1 < x * y ∧ 2 < k ∧ (n ! = x ^ k + y ^ k ∨ n ! + y ^ k = x ^ k) := by
  exact ⟨10, 48, 36, 4, by decide⟩

/-- Erdős and Obláth [ErOb37] proved this is true when $(x,y)=1$ and $k\neq 4$. -/
@[category research solved, AMS 11]
theorem erdos_399.variants.erdos_oblath {n x y k : ℕ} :
    x.Coprime y → 1 < x * y → 2 < k → k ≠ 4 →
      n ! ≠ x ^ k + y ^ k ∧ n ! + y ^ k ≠ x ^ k := by
  sorry

/-- Pollack and Shapiro [PoSh73] proved there are no solutions to $n!=x^4-1$. -/
@[category research solved, AMS 11]
theorem erdos_399.variants.pollack_shapiro (n x : ℕ) : n ! + 1 ≠ x ^ 4 := by
  sorry

/--
Cambie has also observed that considerations modulo $8$ rule out any solutions to $n!=x^4+y^4$ with
$(x,y)=1$ and $xy>1$.
-/
@[category research solved, AMS 11]
theorem erdos_399.variants.cambie {n x y : ℕ} :
    x.Coprime y → 1 < x * y → n ! ≠ x ^ 4 + y ^ 4 := by
  intro hxy h1 heq
  rcases Nat.lt_or_ge n 4 with hn | hn
  · -- n ≤ 3: n! ≤ 6, but x*y > 1 forces max x y ≥ 2, so x^4 + y^4 ≥ 16.
    have hfact_le : n ! ≤ 6 := by
      interval_cases n <;> decide
    have hxy2 : 2 ≤ x ∨ 2 ≤ y := by
      by_contra hc
      simp only [not_or, not_le] at hc
      obtain ⟨hx, hy⟩ := hc
      interval_cases x <;> interval_cases y <;> omega
    have hbig : 16 ≤ x ^ 4 + y ^ 4 := by
      rcases hxy2 with hx | hy
      · have h16 : (2 : ℕ) ^ 4 ≤ x ^ 4 := Nat.pow_le_pow_left hx 4
        omega
      · have h16 : (2 : ℕ) ^ 4 ≤ y ^ 4 := Nat.pow_le_pow_left hy 4
        omega
    omega
  · -- 4 ≤ n: 8 ∣ n!, but coprimality ⇒ not both even ⇒ (x^4 + y^4) % 8 ∈ {1,2}.
    have h4le : (4 : ℕ) ! ∣ n ! := Nat.factorial_dvd_factorial hn
    have h8 : (8 : ℕ) ∣ n ! := dvd_trans (by decide) h4le
    have h8' : (8 : ℕ) ∣ (x ^ 4 + y ^ 4) := by rw [← heq]; exact h8
    have hnotboth2 : x % 2 = 1 ∨ y % 2 = 1 := by
      by_contra hc
      simp only [not_or] at hc
      obtain ⟨hx0, hy0⟩ := hc
      have hx0' : x % 2 = 0 := by omega
      have hy0' : y % 2 = 0 := by omega
      have hx2 : (2 : ℕ) ∣ x := Nat.dvd_of_mod_eq_zero hx0'
      have hy2 : (2 : ℕ) ∣ y := Nat.dvd_of_mod_eq_zero hy0'
      have hg : (2 : ℕ) ∣ Nat.gcd x y := Nat.dvd_gcd hx2 hy2
      rw [(hxy : Nat.gcd x y = 1)] at hg
      norm_num at hg
    have parity4 : ∀ z : ℕ, z ^ 4 % 8 = z % 2 := by
      intro z
      rcases Nat.even_or_odd z with ⟨k, hk⟩ | ⟨k, hk⟩
      · subst hk
        have heqz : (k + k) ^ 4 = 8 * (2 * k ^ 4) := by ring
        rw [heqz]; omega
      · subst hk
        have heqz : (2 * k + 1) ^ 4 = 8 * (2 * k ^ 4 + 4 * k ^ 3 + 3 * k ^ 2 + k) + 1 := by ring
        rw [heqz]; omega
    have hx4 := parity4 x
    have hy4 := parity4 y
    omega

/--
Erdős and Obláth observed that the Bertrand-style fact (first proved by Breusch [Br32]) that, if
$q_i$ is the sequence of primes congruent to $3\pmod{4}$ then $q_{i+1}<2q_i$ except for $q_1=3$,
together with Fermat's theorem on the sums of two squares implies that the only solution to
$n!=x^2+y^2$ is $6!=12^2+24^2$.
-/
@[category research solved, AMS 11]
theorem erdos_399.variants.sum_two_squares :
    ∀ {n x y : ℕ}, 1 < x * y → n ! = x ^ 2 + y ^ 2 →
      n = 6 ∧ (x = 12 ∧ y = 24 ∨ x = 24 ∧ y = 12) := by
  sorry

end Erdos399

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

nosorry fetch erdos-399
nosorry submit erdos-399 nosorry/erdos-399/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.