/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil

Erdős Problem 400

Reference: erdosproblems.com/400

open Nat Filter Finsetopen scoped Asymptotics Topologynamespace Erdos400

For any $k\geq 2$ let $g_k(n)$ denote the maximum value of $(a_1+\cdots+a_k)-n$ where $a_1,\ldots,a_k$ are integers such that $a_1!\cdots a_k! \mid n!$.

noncomputable def g (k n : ) : := sSup { (( i, a i) - n) | (a : Fin k ) (_ : ( i, (a i) !) n !) }

Can one show that $\sum_{n\leq x}g_k(n) \sim c_k x\log x$ for some constant $c_k$?

@[category research open, AMS 11] theorem erdos_400.parts.i : answer(sorry) ∀ᵉ (k 2), c : , (fun x : ( n Icc 1 x, (g k n : ))) ~[atTop] (fun x : c * x * Real.log x) := True k 2, c, (fun x n Icc 1 x, (g k n)) ~[atTop] fun x c * x * Real.log x All goals completed! 🐙

Is it true that there is a constant $c_k$ such that for almost all $n < x$ we have $g_k(n)=c_k\log x+o(\log x)$?

@[category research open, AMS 11] theorem erdos_400.parts.ii : answer(sorry) ∀ᵉ (k 2), c : , ε > 0, Tendsto (fun x : (((Icc 1 x).filter (fun n |(g k n : ) - c * Real.log x| ε * Real.log x)).card : ) / x) atTop (𝓝 1) := True k 2, c, ε > 0, Tendsto (fun x (#({n Icc 1 x | |(g k n) - c * Real.log x| ε * Real.log x})) / x) atTop (𝓝 1) All goals completed! 🐙

Erdős and Graham write that it is easy to show that $g_k(n) \ll_k \log n$ always, but the best possible constant is unknown.

@[category research solved, AMS 11] theorem erdos_400.variants.upper_bound (k : ) (hk : k 2) : (fun n : (g k n : )) (fun n : Real.log (n : )) := k:hk:k 2(fun n (g k n)) =O[atTop] fun n Real.log n All goals completed! 🐙

For $k \ge 2$, $g_k(n) > 0$. We show this by choosing $a = (n, 1, 0, \ldots, 0)$.

n:k':h:k' + 2 2a:Fin (k' + 2) := fun i if i = 0 then n else if i = 1 then 1 else 0ha_def:a = fun i if i = 0 then n else if i = 1 then 1 else 0h_prod: i, (a i)! = n !h_sum: i, a i = n + 1hmem:1 {x | b, (_ : i, (b i)! n !), i, b i - n = x}hbdd:BddAbove {x | b, (_ : i, (b i)! n !), i, b i - n = x}0 < sSup {x | a, (_ : i, (a i)! n !), i, a i - n = x} All goals completed! 🐙end Erdos400