{
  "id": "2026",
  "ident": "NS.02026",
  "slug": "erdos-408",
  "title": "Erdős Problem 408",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Let $\\phi(n)$ be the Euler totient function and $\\phi_k(n)$ be the iterated $\\phi$ function, so\nthat $\\phi_1(n)=\\phi(n)$ and $\\phi_k(n)=\\phi(\\phi_{k-1}(n))$. Let\n$$f(n) = \\min\\{k : \\phi_k(n)=1\\}.$$\nDoes $f(n)/\\log n$ have a distribution function?\n\nWe ask for a distribution function $F$ (non-decreasing, with $F(-\\infty) = 0$ and\n$F(+\\infty) = 1$) such that, for every continuity point $c$ of $F$, the set\n$\\{n : f(n)/\\log n \\leq c\\}$ has natural density $F(c)$. For $n \\leq 1$ the quotient is $0$ in\nLean, which does not affect densities. Erdős, Granville, Pomerance and Spiro [EGPS90] proved\nthat the answer is yes, conditional on a form of the Elliott–Halberstam conjecture.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos408.erdos_408.parts.i",
  "statement_lean": "theorem erdos_408.parts.i :\n    ∃ F : ℝ → ℝ, Monotone F ∧ Tendsto F atBot (𝓝 0) ∧ Tendsto F atTop (𝓝 1) ∧\n      ∀ c : ℝ, ContinuousAt F c →\n        {n : ℕ | (f n : ℝ) / Real.log n ≤ c}.HasDensity (F c)",
  "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 408\n\n*References:*\n- [erdosproblems.com/408](https://www.erdosproblems.com/408)\n- [OEIS A003434](https://oeis.org/A003434): the values $f(n)$ for $n \\geq 2$.\n- [ErGr80] Erdős, P. and Graham, R., *Old and new problems and results in combinatorial number\n  theory*. Monographies de L'Enseignement Mathématique (1980).\n- [Pi29] Pillai, S. Sivasankaranarayana, *On a function connected with $\\phi(n)$*. Bull. Amer.\n  Math. Soc. 35 (1929), 837-841.\n  [doi:10.1090/S0002-9904-1929-04800-6](https://doi.org/10.1090/S0002-9904-1929-04800-6)\n- [Sh50] Shapiro, Harold N., *On the iterates of a certain class of arithmetic functions*. Comm.\n  Pure Appl. Math. 3 (1950), 259-272.\n- [EGPS90] Erdős, P., Granville, A., Pomerance, C. and Spiro, C., *On the normal behavior of the\n  iterates of some arithmetic functions*. Analytic number theory (Allerton Park, IL, 1989),\n  Progr. Math. 85 (1990), 165-204.\n- [Gu04] Guy, Richard K., *Unsolved problems in number theory*. Third edition, Springer (2004),\n  Problem B41.\n- [FKL10] Ford, K., Konyagin, S. V. and Luca, F., *Prime chains and Pratt trees*. Geom. Funct.\n  Anal. 20 (2010), 1231-1258. [arXiv:0904.0473](https://arxiv.org/abs/0904.0473)\n  [doi:10.1007/s00039-010-0089-0](https://doi.org/10.1007/s00039-010-0089-0)\n-/\n\n@[expose] public section\n\nopen Filter\nopen scoped Topology\n\nnamespace Erdos408\n\n/--\n`f n` is $f(n) = \\min\\{k \\geq 1 : \\phi_k(n) = 1\\}$, where $\\phi_1 = \\phi$ is Euler's totient\nfunction and $\\phi_k(n) = \\phi(\\phi_{k-1}(n))$. As in the source, $k$ starts at $1$, so\n$f(1) = 1$. Every iterate of $\\phi$ at $0$ is $0$, so `sInf ∅ = 0` gives the junk value\n$f(0) = 0$.\n-/\nnoncomputable def f (n : ℕ) : ℕ :=\n  sInf {k : ℕ | 1 ≤ k ∧ Nat.totient^[k] n = 1}\n\n/-- The junk value $f(0) = 0$. -/\n@[category test, AMS 11]\ntheorem f_zero : f 0 = 0 := by\n  rw [f, Nat.sInf_eq_zero]\n  refine Or.inr (Set.eq_empty_iff_forall_notMem.2 fun k hk ↦ ?_)\n  have h := hk.2\n  rw [Function.iterate_fixed Nat.totient_zero] at h\n  omega\n\n/-- $\\phi(1) = 1$, so $f(1) = 1$ (the iteration count starts at $1$, not $0$). -/\n@[category test, AMS 11]\ntheorem f_one : f 1 = 1 := by\n  apply le_antisymm\n  · exact Nat.sInf_le ⟨le_rfl, by simp⟩\n  · exact le_csInf ⟨1, le_rfl, by simp⟩ fun _ hk ↦ hk.1\n\n/-- $\\phi(2) = 1$, so $f(2) = 1$. -/\n@[category test, AMS 11]\ntheorem f_two : f 2 = 1 := by\n  apply le_antisymm\n  · exact Nat.sInf_le ⟨le_rfl, by simp⟩\n  · exact le_csInf ⟨1, le_rfl, by simp⟩ fun _ hk ↦ hk.1\n\n/-- Since $\\phi(2^{j+1}) = 2^j$, we have $f(2^k) = k$ for every $k \\geq 1$. -/\n@[category test, AMS 11]\ntheorem f_two_pow (k : ℕ) (hk : 1 ≤ k) : f (2 ^ k) = k := by\n  have key : ∀ j, j ≤ k → Nat.totient^[j] (2 ^ k) = 2 ^ (k - j) := by\n    intro j\n    induction j with\n    | zero => intro _; simp\n    | succ j ih =>\n      intro hj\n      rw [Function.iterate_succ_apply', ih (by omega)]\n      obtain ⟨i, hi⟩ : ∃ i, k - j = i + 1 := ⟨k - j - 1, by omega⟩\n      rw [hi, Nat.totient_prime_pow_succ Nat.prime_two, show k - (j + 1) = i by omega]\n      simp\n  have hk1 : Nat.totient^[k] (2 ^ k) = 1 := by rw [key k le_rfl, Nat.sub_self, pow_zero]\n  apply le_antisymm\n  · exact Nat.sInf_le ⟨hk, hk1⟩\n  refine le_csInf ⟨k, hk, hk1⟩ fun j hj ↦ ?_\n  by_contra hlt\n  have h2 : 2 ≤ 2 ^ (k - j) := Nat.le_self_pow (by omega) 2\n  have h3 := hj.2\n  rw [key j (by omega)] at h3\n  omega\n\n/--\nLet $\\phi(n)$ be the Euler totient function and $\\phi_k(n)$ be the iterated $\\phi$ function, so\nthat $\\phi_1(n)=\\phi(n)$ and $\\phi_k(n)=\\phi(\\phi_{k-1}(n))$. Let\n$$f(n) = \\min\\{k : \\phi_k(n)=1\\}.$$\nDoes $f(n)/\\log n$ have a distribution function?\n\nWe ask for a distribution function $F$ (non-decreasing, with $F(-\\infty) = 0$ and\n$F(+\\infty) = 1$) such that, for every continuity point $c$ of $F$, the set\n$\\{n : f(n)/\\log n \\leq c\\}$ has natural density $F(c)$. For $n \\leq 1$ the quotient is $0$ in\nLean, which does not affect densities. Erdős, Granville, Pomerance and Spiro [EGPS90] proved\nthat the answer is yes, conditional on a form of the Elliott–Halberstam conjecture.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_408.parts.i :\n    ∃ F : ℝ → ℝ, Monotone F ∧ Tendsto F atBot (𝓝 0) ∧ Tendsto F atTop (𝓝 1) ∧\n      ∀ c : ℝ, ContinuousAt F c →\n        {n : ℕ | (f n : ℝ) / Real.log n ≤ c}.HasDensity (F c) := by\n  sorry\n\n/--\nIs $f(n)/\\log n$ almost always constant?\n\nWe read this as: is there a constant $\\alpha$ such that, for every $\\epsilon > 0$, the set of\n$n$ with $|f(n)/\\log n - \\alpha| < \\epsilon$ has natural density $1$? Erdős, Granville,\nPomerance and Spiro [EGPS90] proved that, conditional on a form of the Elliott–Halberstam\nconjecture, $f(n)$ has normal order $\\alpha \\log n$ for some constant $\\alpha > 0$, so that the\nanswer is yes under this hypothesis.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_408.parts.ii :\n    ∃ α : ℝ, ∀ ε > (0 : ℝ),\n      {n : ℕ | |(f n : ℝ) / Real.log n - α| < ε}.HasDensity 1 := by\n  sorry\n\n/--\nPillai [Pi29] proved that, for all $n \\geq 2$,\n$$\\left\\lfloor \\frac{\\log n - \\log 2}{\\log 3} \\right\\rfloor + 1 \\leq f(n) \\leq\n  \\left\\lfloor \\frac{\\log n}{\\log 2} \\right\\rfloor + 1.$$\nThese are Theorems I and III of [Pi29]; Pillai's function $R(n)$ is the least $r$ with\n$\\phi_r(n) = 1$, which is $f(n)$. The lower bound is attained at $n = 2 \\cdot 3^k$, and\n$f(2^k) = k$ (`Erdos408.f_two_pow`), so the upper bound cannot be replaced by $f(n) < \\log_2 n$.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_408.variants.pillai (n : ℕ) (hn : 2 ≤ n) :\n    ⌊(Real.log n - Real.log 2) / Real.log 3⌋₊ + 1 ≤ f n ∧\n      f n ≤ ⌊Real.log n / Real.log 2⌋₊ + 1 := by\n  sorry\n\n/--\nThe third question asks what can be said about the largest prime factor $P^+(\\phi_k(n))$ when,\nsay, $k = \\log\\log n$; it is open-ended and is not formalised. The site remarks that it is likely\ntrue that, if $k \\to \\infty$ however slowly with $n$, then $P^+(\\phi_k(n)) \\leq n^{o(1)}$ for\nalmost all $n$.\n\nFord, Konyagin and Luca [FKL10, Theorem 5] proved that for every $\\epsilon > 0$ and $\\delta > 0$\nthere is an integer $k$ such that, for all large $x$, at least $(1 - \\epsilon)x$ integers\n$n \\leq x$ satisfy $P^+(\\phi_k(n)) \\leq x^{\\delta}$. Since $P^+(\\phi(m)) \\leq P^+(m)$, this gives\nthe remark above for every $k = k(n) \\to \\infty$.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_408.variants.ford_konyagin_luca (ε δ : ℝ) (hε : 0 < ε) (hδ : 0 < δ) :\n    ∃ k : ℕ, ∀ᶠ x : ℝ in atTop, (1 - ε) * x ≤\n      ((Finset.Icc 1 ⌊x⌋₊).filter fun n ↦\n        ((Nat.totient^[k] n).maxPrimeFac : ℝ) ≤ x ^ δ).card := by\n  sorry\n\nend Erdos408\n",
  "statement_hash": "25fc2a58962a61050d5c4a67b9116f933c71bfb515859706eaf54a49dce4004a",
  "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."
}