{
  "id": "3304",
  "ident": "NS.03304",
  "slug": "erdos-820",
  "title": "Erdős Problem 820",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Let $H(n)$ be the smallest integer $l$ such that there exists $k < l$ with $(k^n-1, l^n-1) = 1$.\nIs it true that $H(n) = 3$ infinitely often? That is, is $(2^n-1, 3^n-1) = 1$ for infinitely\nmany $n$ (see `Erdos820.H_eq_three_iff`)?\n\nThe request to estimate $H(n)$ is open-ended and not formalised; the variants below state the\nspecific questions that are asked. See also Erdős Problem 770.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos820.erdos_820",
  "statement_lean": "theorem erdos_820 : {n : ℕ | H n = 3}.Infinite",
  "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 820\n\n*References:*\n- [erdosproblems.com/820](https://www.erdosproblems.com/820)\n- [Er74b] Erdős, P., *Remarks on some problems in number theory*. Math. Balkanica (1974),\n  197-202.\n- [OEIS A263647](https://oeis.org/A263647): the $n$ with $(2^n-1, 3^n-1) = 1$.\n-/\n\n@[expose] public section\n\nopen Filter\n\nnamespace Erdos820\n\n/-- $H(n)$ is the smallest integer $l$ such that there is some $k < l$ with\n$(k^n-1, l^n-1) = 1$.\n\nWe take $k$ and $l$ to be integers with $k \\geq 2$, so that $k^n - 1 \\geq 1$ for $n \\geq 1$.\nSmaller $k$ give degenerate values: over the integers $k = 0$ gives $(-1, l^n-1) = 1$, and $k = 1$\ngives $(0, l^n-1) = l^n-1$, which is $1$ for $n = 1$, $l = 2$. Both would contradict the value\n$H(1) = 3$ listed in the source.\n\nFor $n \\geq 1$ the set is nonempty (see `Erdos820.H_spec`). For $n = 0$ it is empty, and\n`H 0 = 0` by the `sInf ∅` convention; the only statement whose truth depends on `H 0` is\n`Erdos820.H_eq_three_iff`, where both sides are false. -/\nnoncomputable def H (n : ℕ) : ℕ :=\n  sInf {l : ℕ | ∃ k : ℕ, 2 ≤ k ∧ k < l ∧ Nat.Coprime (k ^ n - 1) (l ^ n - 1)}\n\n/-- $K(n)$ is the smallest integer $k \\geq 2$ such that $(k^n-1, 2^n-1) = 1$. As for\n`Erdos820.H`, smaller $k$ are excluded because they give degenerate values.\n\nFor $n \\geq 2$ the value $k = 2$ never works, and $k = 2^n - 1$ always works. For $n = 1$ we\nget $K(1) = 2$, and for $n = 0$ the set is empty, so `K 0 = 0`. -/\nnoncomputable def K (n : ℕ) : ℕ :=\n  sInf {k : ℕ | 2 ≤ k ∧ Nat.Coprime (k ^ n - 1) (2 ^ n - 1)}\n\n/-- For $n \\geq 1$ the minimum defining $H(n)$ is attained: there is $k$ with $2 \\leq k < H(n)$\nand $(k^n-1, H(n)^n-1) = 1$. For $n \\geq 2$, the pair $k = 2$, $l = 2^n - 1$ shows that the set\nis nonempty. For $n = 1$, take $k = 2$, $l = 3$. -/\n@[category API, AMS 11]\ntheorem H_spec {n : ℕ} (hn : 1 ≤ n) :\n    ∃ k : ℕ, 2 ≤ k ∧ k < H n ∧ Nat.Coprime (k ^ n - 1) (H n ^ n - 1) := by\n  have hne : {l : ℕ | ∃ k : ℕ, 2 ≤ k ∧ k < l ∧ Nat.Coprime (k ^ n - 1) (l ^ n - 1)}.Nonempty := by\n    obtain rfl | hn2 := hn.eq_or_lt\n    · exact ⟨3, 2, le_rfl, by norm_num, by decide⟩\n    · have h4 : 4 ≤ 2 ^ n :=\n        calc 4 = 2 ^ 2 := by norm_num\n          _ ≤ 2 ^ n := Nat.pow_le_pow_right (by norm_num) hn2\n      refine ⟨2 ^ n - 1, 2, le_rfl, by omega, ?_⟩\n      have h1 : 1 ≤ (2 ^ n - 1) ^ n := Nat.one_le_pow _ _ (by omega)\n      exact Nat.Coprime.coprime_dvd_left (dvd_pow_self _ (by omega))\n        ((Nat.coprime_self_sub_right h1).2 (Nat.coprime_one_right _))\n  exact Nat.sInf_mem hne\n\n/-- $H(n) = 3$ if and only if $(2^n-1, 3^n-1) = 1$. This holds for every $n$, including\n$n = 0$, where both sides are false. -/\n@[category API, AMS 11]\ntheorem H_eq_three_iff (n : ℕ) : H n = 3 ↔ Nat.Coprime (2 ^ n - 1) (3 ^ n - 1) := by\n  constructor\n  · intro h\n    have hne : {l : ℕ | ∃ k : ℕ, 2 ≤ k ∧ k < l ∧ Nat.Coprime (k ^ n - 1) (l ^ n - 1)}.Nonempty :=\n      Nat.nonempty_of_pos_sInf (by unfold H at h; omega)\n    have hmem : H n ∈ {l : ℕ | ∃ k : ℕ, 2 ≤ k ∧ k < l ∧ Nat.Coprime (k ^ n - 1) (l ^ n - 1)} :=\n      Nat.sInf_mem hne\n    rw [h] at hmem\n    obtain ⟨k, hk2, hk3, hk⟩ := hmem\n    obtain rfl : k = 2 := by omega\n    exact hk\n  · intro h\n    unfold H\n    refine le_antisymm (Nat.sInf_le ⟨2, le_rfl, by norm_num, h⟩)\n      (le_csInf ⟨3, 2, le_rfl, by norm_num, h⟩ ?_)\n    rintro l ⟨k, hk2, hkl, -⟩\n    omega\n\n/-- The first values of $H(n)$, for $1 \\leq n \\leq 10$, are $3, 3, 3, 6, 3, 18, 3, 6, 3, 12$. -/\n@[category test, AMS 11]\ntheorem H_one_to_ten :\n    H 1 = 3 ∧ H 2 = 3 ∧ H 3 = 3 ∧ H 4 = 6 ∧ H 5 = 3 ∧ H 6 = 18 ∧ H 7 = 3 ∧ H 8 = 6 ∧\n      H 9 = 3 ∧ H 10 = 12 := by\n  have key : ∀ n m : ℕ, (∃ k, 2 ≤ k ∧ k < m ∧ Nat.Coprime (k ^ n - 1) (m ^ n - 1)) →\n      (∀ l < m, ∀ k < l, 2 ≤ k → ¬ Nat.Coprime (k ^ n - 1) (l ^ n - 1)) → H n = m := by\n    intro n m hm hlt\n    unfold H\n    refine le_antisymm (Nat.sInf_le hm) (le_csInf ⟨m, hm⟩ ?_)\n    rintro l ⟨k, hk2, hkl, hk⟩\n    by_contra! h\n    exact hlt l h k hkl hk2 hk\n  have three (n : ℕ) (h : Nat.Coprime (2 ^ n - 1) (3 ^ n - 1)) : H n = 3 :=\n    (H_eq_three_iff n).2 h\n  exact ⟨three 1 (by decide), three 2 (by decide), three 3 (by decide),\n    key 4 6 ⟨5, by decide⟩ (by decide +kernel), three 5 (by decide),\n    key 6 18 ⟨14, by decide⟩ (by decide +kernel), three 7 (by decide),\n    key 8 6 ⟨5, by decide⟩ (by decide +kernel), three 9 (by decide),\n    key 10 12 ⟨11, by decide⟩ (by decide +kernel)⟩\n\n/--\nLet $H(n)$ be the smallest integer $l$ such that there exists $k < l$ with $(k^n-1, l^n-1) = 1$.\nIs it true that $H(n) = 3$ infinitely often? That is, is $(2^n-1, 3^n-1) = 1$ for infinitely\nmany $n$ (see `Erdos820.H_eq_three_iff`)?\n\nThe request to estimate $H(n)$ is open-ended and not formalised; the variants below state the\nspecific questions that are asked. See also Erdős Problem 770.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_820 : {n : ℕ | H n = 3}.Infinite := by\n  sorry\n\n/--\nIs it true that there exists some constant $c > 0$ such that, for all $\\epsilon > 0$,\n$$\nH(n) > \\exp\\left(n^{(c-\\epsilon)/\\log\\log n}\\right)\n$$\nfor infinitely many $n$ and\n$$\nH(n) < \\exp\\left(n^{(c+\\epsilon)/\\log\\log n}\\right)\n$$\nfor all large enough $n$?\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_820.variants.log_log_exponent :\n    ∃ c > (0 : ℝ), ∀ ε > (0 : ℝ),\n      (∃ᶠ n : ℕ in atTop,\n        Real.exp ((n : ℝ) ^ ((c - ε) / Real.log (Real.log (n : ℝ)))) < (H n : ℝ)) ∧\n      ∀ᶠ n : ℕ in atTop,\n        (H n : ℝ) < Real.exp ((n : ℝ) ^ ((c + ε) / Real.log (Real.log (n : ℝ)))) := by\n  sorry\n\n/--\nLet $K(n)$ be the smallest $k$ such that $(k^n-1, 2^n-1) = 1$. Does a similar upper bound hold\nfor $K(n)$? That is, is there a constant $c > 0$ such that, for all $\\epsilon > 0$,\n$$\nK(n) < \\exp\\left(n^{(c+\\epsilon)/\\log\\log n}\\right)\n$$\nfor all large enough $n$?\n\nWe read \"similar\" as an upper bound of the same shape, with its own constant $c$, which need\nnot be the same as in `Erdos820.erdos_820.variants.log_log_exponent`.\n-/\n@[category research open, question, AMS 11]\ntheorem erdos_820.variants.two_pow_upper :\n    ∃ c > (0 : ℝ), ∀ ε > (0 : ℝ), ∀ᶠ n : ℕ in atTop,\n      (K n : ℝ) < Real.exp ((n : ℝ) ^ ((c + ε) / Real.log (Real.log (n : ℝ)))) := by\n  sorry\n\n/--\nErdős [Er74b] proved that there exists a constant $c > 0$ such that\n$$\nH(n) > \\exp\\left(n^{c/(\\log\\log n)^2}\\right)\n$$\nfor infinitely many $n$.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_820.variants.erdos_lower :\n    ∃ c > (0 : ℝ), ∃ᶠ n : ℕ in atTop,\n      Real.exp ((n : ℝ) ^ (c / Real.log (Real.log (n : ℝ)) ^ 2)) < (H n : ℝ) := by\n  sorry\n\nend Erdos820\n",
  "statement_hash": "769e1ea948e585cfe912951ea74ad581606c3e75c8941915a5df8bb3b820d674",
  "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."
}