{
  "id": "6539",
  "ident": "NS.06539",
  "slug": "oeis-401006",
  "title": "Decimal concatenation of a cofactor and the largest prime factor",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "If we start at $n \\ge 2$, and repeatedly apply the map $k \\mapsto a(k)$, we will eventually\nreach a prime, which is then a fixed point.\n\n— [OEIS A401006](https://oeis.org/A401006)",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA401006.eventually_prime",
  "statement_lean": "theorem eventually_prime : ∀ n : ℕ, 2 ≤ n → ReachesPrime n",
  "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-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Decimal concatenation of a cofactor and the largest prime factor\n\nFor a composite positive integer $n$, let $p$ be its largest prime factor. The sequence value\n$a(n)$ concatenates the decimal representations of $n/p$ and $p$, in that order. It fixes primes\nand one, and is extended here by $a(0)=0$. OEIS A397122 records the prime reached by iterating\nthis map from each starting value, or $-1$ if no prime is reached.\n\n*References:*\n- [OEIS A401006](https://oeis.org/A401006)\n- [OEIS A397122](https://oeis.org/A397122)\n-/\n\n@[expose] public section\n\nnamespace OeisA401006\n\n/-- The number of decimal digits of a natural number, counting zero as one digit. -/\ndef decimalDigitCount (n : ℕ) : ℕ :=\n  if n = 0 then 1 else (Nat.digits 10 n).length\n\n/-- Append the decimal digits of `b` to those of `a`. -/\ndef decimalAppend (a b : ℕ) : ℕ :=\n  a * 10 ^ decimalDigitCount b + b\n\n/-- Zero, one, and primes are fixed; a composite number is replaced by its\ncofactor after removing one largest prime factor, followed by that prime factor in decimal. -/\ndef a (n : ℕ) : ℕ :=\n  if n ≤ 1 then n\n  else if n.Prime then n\n  else decimalAppend (n / n.maxPrimeFac) n.maxPrimeFac\n\n/-- Zero is the artificial fixed point outside the official OEIS indexing. -/\n@[category API, AMS 11]\ntheorem a_zero : a 0 = 0 := by\n  simp [a]\n\n/-- One is a fixed point. -/\n@[category API, AMS 11]\ntheorem a_one : a 1 = 1 := by\n  simp [a]\n\n/-- Every prime is a fixed point. -/\n@[category API, AMS 11]\ntheorem a_prime {p : ℕ} (hp : p.Prime) : a p = p := by\n  simp [a, hp, not_le_of_gt hp.one_lt]\n\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 0 := by\n  exact a_zero\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 1 := by\n  exact a_one\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 2 := by\n  norm_num [a]\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 3 := by\n  norm_num [a]\n\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 22 := by\n  norm_num [a, decimalAppend, decimalDigitCount, Nat.maxPrimeFac,\n    Nat.primeFactorsList, List.getLastI]\n\n@[category test, AMS 11]\ntheorem a_5 : a 5 = 5 := by\n  norm_num [a]\n\n@[category test, AMS 11]\ntheorem a_6 : a 6 = 23 := by\n  norm_num [a, decimalAppend, decimalDigitCount, Nat.maxPrimeFac,\n    Nat.primeFactorsList, List.getLastI]\n\n@[category test, AMS 11]\ntheorem a_7 : a 7 = 7 := by\n  norm_num [a]\n\n@[category test, AMS 11]\ntheorem a_8 : a 8 = 42 := by\n  norm_num [a, decimalAppend, decimalDigitCount, Nat.maxPrimeFac,\n    Nat.primeFactorsList, List.getLastI]\n\n@[category test, AMS 11]\ntheorem a_44 : a 44 = 411 := by\n  norm_num [a, decimalAppend, decimalDigitCount, Nat.maxPrimeFac,\n    Nat.primeFactorsList, List.getLastI]\n\n@[category test, AMS 11]\ntheorem a_49 : a 49 = 77 := by decide +kernel\n\n@[category test, AMS 11]\ntheorem a_77 : a 77 = 711 := by decide +kernel\n\n@[category test, AMS 11]\ntheorem a_711 : a 711 = 979 := by decide +kernel\n\n@[category test, AMS 11]\ntheorem a_979 : a 979 = 1189 := by decide +kernel\n\n@[category test, AMS 11]\ntheorem a_1189 : a 1189 = 2941 := by decide +kernel\n\n@[category test, AMS 11]\ntheorem a_2941 : a 2941 = 17173 := by\n  have hf : Nat.maxPrimeFac (17 * 173) = 173 := by\n    rw [Nat.maxPrimeFac_mul (by decide) (by decide),\n      (by norm_num : Nat.Prime 17).maxPrimeFac_eq_self,\n      (by norm_num : Nat.Prime 173).maxPrimeFac_eq_self]\n    norm_num\n  change Nat.maxPrimeFac 2941 = 173 at hf\n  norm_num [a, hf, decimalAppend, decimalDigitCount]\n\n@[category test, AMS 11]\ntheorem a_17173 : a 17173 = 131321 := by\n  have hf : Nat.maxPrimeFac (13 * 1321) = 1321 := by\n    rw [Nat.maxPrimeFac_mul (by decide) (by decide),\n      (by norm_num : Nat.Prime 13).maxPrimeFac_eq_self,\n      (by norm_num : Nat.Prime 1321).maxPrimeFac_eq_self]\n    norm_num\n  change Nat.maxPrimeFac 17173 = 1321 at hf\n  norm_num [a, hf, decimalAppend, decimalDigitCount]\n\n/-- Decimal append is larger than the corresponding product when both inputs are positive. -/\n@[category API, AMS 11]\ntheorem mul_lt_decimal_append {x y : ℕ} (hx : 0 < x) (hy : 0 < y) :\n    x * y < decimalAppend x y := by\n  have hypow : y < 10 ^ decimalDigitCount y := by\n    simpa [decimalDigitCount, hy.ne'] using\n      (Nat.lt_base_pow_length_digits (b := 10) (m := y) (by norm_num))\n  exact (Nat.mul_lt_mul_of_pos_left hypow hx).trans (Nat.lt_add_of_pos_right hy)\n\n/-- Applying $a$ to a composite integer above one strictly increases its value. -/\n@[category API, AMS 11]\ntheorem lt_a_of_not_prime {n : ℕ} (hn : 1 < n) (hprime : ¬n.Prime) : n < a n := by\n  have hp : n.maxPrimeFac.Prime := Nat.prime_maxPrimeFac_of_one_lt n hn\n  have hq : 0 < n / n.maxPrimeFac := Nat.div_pos Nat.maxPrimeFac_le hp.pos\n  have hlt := mul_lt_decimal_append hq hp.pos\n  rw [Nat.div_mul_cancel Nat.maxPrimeFac_dvd] at hlt\n  simpa [a, not_le.mpr hn, hprime] using hlt\n\n/-- A starting value reaches a prime after finitely many iterations of $a$. -/\ndef ReachesPrime (n : ℕ) : Prop :=\n  ∃ k : ℕ, ((a^[k]) n).Prime\n\n/-- Zero never reaches a prime under iteration. -/\n@[category test, AMS 11]\ntheorem not_reaches_prime_zero : ¬ ReachesPrime 0 := by\n  rintro ⟨k, hk⟩\n  rw [Function.iterate_fixed a_zero k] at hk\n  exact Nat.not_prime_zero hk\n\n/-- One never reaches a prime under iteration. -/\n@[category test, AMS 11]\ntheorem not_reaches_prime_one : ¬ ReachesPrime 1 := by\n  rintro ⟨k, hk⟩\n  rw [Function.iterate_fixed a_one k] at hk\n  exact Nat.not_prime_one hk\n\n@[category test, AMS 11]\ntheorem prime_131321 : Nat.Prime 131321 := by norm_num\n\n/-- The orbit starting from $49$ reaches the prime $131321$ after seven steps. -/\n@[category test, AMS 11]\ntheorem reaches_prime_49 : ReachesPrime 49 := by\n  have orbit : (a^[7]) 49 = 131321 := calc\n    (a^[7]) 49 = (a^[6]) (a 49) := Function.iterate_succ_apply a 6 49\n    _ = (a^[6]) 77 := congrArg (a^[6]) a_49\n    _ = (a^[5]) (a 77) := Function.iterate_succ_apply a 5 77\n    _ = (a^[5]) 711 := congrArg (a^[5]) a_77\n    _ = (a^[4]) (a 711) := Function.iterate_succ_apply a 4 711\n    _ = (a^[4]) 979 := congrArg (a^[4]) a_711\n    _ = (a^[3]) (a 979) := Function.iterate_succ_apply a 3 979\n    _ = (a^[3]) 1189 := congrArg (a^[3]) a_979\n    _ = (a^[2]) (a 1189) := Function.iterate_succ_apply a 2 1189\n    _ = (a^[2]) 2941 := congrArg (a^[2]) a_1189\n    _ = (a^[1]) (a 2941) := Function.iterate_succ_apply a 1 2941\n    _ = (a^[1]) 17173 := congrArg (a^[1]) a_2941\n    _ = (a^[0]) (a 17173) := Function.iterate_succ_apply a 0 17173\n    _ = (a^[0]) 131321 := congrArg (a^[0]) a_17173\n    _ = 131321 := rfl\n  exact ⟨7, (congrArg Nat.Prime orbit).mpr prime_131321⟩\n\n/--\nIf we start at $n \\ge 2$, and repeatedly apply the map $k \\mapsto a(k)$, we will eventually\nreach a prime, which is then a fixed point.\n\n— [OEIS A401006](https://oeis.org/A401006)\n-/\n@[category research open, AMS 11]\ntheorem eventually_prime : ∀ n : ℕ, 2 ≤ n → ReachesPrime n := by\n  sorry\n\nend OeisA401006\n",
  "statement_hash": "daf1d5df5fd2f2c06c9443f5dbb87036f553f1854ab1c2f62a23ffee7a3df2b5",
  "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."
}