/- 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. -/ module public import FormalConjecturesUtil /-! # Erdős Problem 878 *References:* - [erdosproblems.com/878](https://www.erdosproblems.com/878) - [Er84e] Erdős, P., _On two unconventional number theoretic functions and on some related problems_. (1984), 113--121. - [Ki26] Kitamura, K., _Erdős Problem #878 in Lean_, [GitHub repository](https://github.com/KitaKen1/erdos-878-lean/tree/d4a8eecf0606b3eee7342c2040a31c8c30eb5d76) (2026). -/ @[expose] public section open Filter Asymptotics open scoped Topology Real namespace Erdos878 /-- The function $f(n)=\sum_{p\mid n}p^{\lfloor\log_p n\rfloor}$. -/ noncomputable def f (n : ℕ) : ℕ := ∑ p ∈ n.primeFactors, p ^ Nat.log p n open scoped Classical in /-- The function $F(n)$ from Erdős Problem 878, with nontrivial terms $a_i \ge 2$. -/ noncomputable def F (n : ℕ) : ℕ := ((Finset.Icc 2 n).powerset.filter fun A ↦ A ⊆ Finset.Icc 2 n ∧ (A : Set ℕ).Pairwise (fun a b ↦ Nat.Coprime a b) ∧ ∀ a ∈ A, ∀ p, p.Prime → p ∣ a → p ∣ n).sup fun A ↦ ∑ a ∈ A, a /-- The maximum of an arithmetic function on $\{0,\ldots,x\}$. -/ noncomputable def maxUpTo (g : ℕ → ℕ) (x : ℕ) : ℕ := (Finset.range (x + 1)).sup g /-- The function $H(x)=\sum_{1\le n