{
  "id": "6457",
  "ident": "NS.06457",
  "slug": "oeis-382590",
  "title": "Periodicity of $k$-th prime factors in coupled nonlinear recurrence $a(n)$",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Conjecture: For any $k > 1$, if you take the $k$-th prime factor of each term, you get an\neventually periodic sequence. - _Bryle Morga_, Mar 31 2025\n\nHere the $k$-th prime factor of $a(n)$ is the $k$-th smallest distinct prime divisor of\n$|a(n)|$; for example the second prime factors of $a(5) = 18$, $a(6) = 20$ and $a(7) = 896$\nare $3$, $5$ and $7$.\n\nThis was proved by Terence Tao in a [MathOverflow answer](https://mathoverflow.net/a/490348),\nusing that $a(n)$ divides $a(n+3)$ for all $n$.\nLean formalization by Wentao Li, with AI assistance.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA382590.kthPrimeFactor_periodic",
  "statement_lean": "theorem kthPrimeFactor_periodic : ∀ k : ℕ, k ≥ 2 → ∃ N₀ p : ℕ, p > 0 ∧\n    ∀ n : ℕ, n ≥ N₀ → kthPrimeFactor k (a (n + p)) = kthPrimeFactor k (a 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-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Periodicity of $k$-th prime factors in coupled nonlinear recurrence $a(n)$\n\nThe sequence $a(n)$ is defined by $a(n) = a(n-1)b(n-2) + a(n-2)b(n-1)$\nwhere $b(n) = a(n-1)b(n-2) - a(n-2)b(n-1)$, with $a(0) = b(0) = b(1) = 1$ and $a(1) = 2$.\n\n*References:*\n- [A382590](https://oeis.org/A382590)\n- [mathoverflow/490330](https://mathoverflow.net/questions/490330): B. Morga, \"Peculiar family of\n  recurrence formula where for $n>1$ if you take the $n$-th prime factor of each term, you get an\n  eventually periodic sequence\", Mar. 31, 2025.\n-/\n\n@[expose] public section\n\nnamespace OeisA382590\n\n\nopen Int\n\n/--\nHelper function for a, computing the pair $(a(n), b(n))$ such that:\n$a(n) = a(n-1)b(n-2) + a(n-2)b(n-1)$\n$b(n) = a(n-1)b(n-2) - a(n-2)b(n-1)$\n-/\ndef abPair : ℕ → ℤ × ℤ\n| 0 => (1, 1)\n| 1 => (2, 1)\n| n + 2 =>\n  let (a_n_plus_1, b_n_plus_1) := abPair (n + 1)\n  let (a_n, b_n) := abPair n\n  (a_n_plus_1 * b_n + a_n * b_n_plus_1, a_n_plus_1 * b_n - a_n * b_n_plus_1)\n\n/--\nThe sequence defined by the mutual recurrence relations:\n$a(n) = a(n-1)b(n-2) + a(n-2)b(n-1)$ and $b(n) = a(n-1)b(n-2) - a(n-2)b(n-1)$\nstarting with $a(0) = b(0) = b(1) = 1$ and $a(1) = 2$.\nThe terms are in $\\mathbb{Z}$ due to negative values.\n-/\ndef a (n : ℕ) : ℤ := (abPair n).fst\n\nopen Nat\n\n/--\nThe $k$-th smallest distinct prime factor of an integer $n$ (where $k \\ge 1$).\nThis is defined as the $k$-th element (0-indexed $k-1$) of the increasing list of\ndistinct prime factors of `n.natAbs`.\nReturns 1 if n has fewer than k distinct prime factors or if n is 0, 1, or -1,\nfollowing the informal convention.\n-/\ndef kthPrimeFactor (k : ℕ) (n : ℤ) : ℕ :=\n  if h₀ : k = 0 then 1 else\n  let L := (primeFactorsList n.natAbs).dedup\n  if h_len : k - 1 ≥ L.length then 1 else\n  L[k - 1]\n\n@[category test, AMS 11]\nlemma kthPrimeFactor_two_a_six : kthPrimeFactor 2 (a 6) = 5 := by decide +kernel\n\n@[category test, AMS 11]\nlemma kthPrimeFactor_two_a_seven : kthPrimeFactor 2 (a 7) = 7 := by decide +kernel\n\n\n@[category test, AMS 11]\nlemma a_0 : a 0 = 1 := by rfl\n\n@[category test, AMS 11]\nlemma a_1 : a 1 = 2 := by rfl\n\n@[category test, AMS 11]\nlemma a_2 : a 2 = 3 := by rfl\n\n@[category test, AMS 11]\nlemma a_3 : a 3 = 5 := by rfl\n\n@[category test, AMS 11]\nlemma a_4 : a 4 = 8 := by rfl\n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nConjecture: For any $k > 1$, if you take the $k$-th prime factor of each term, you get an\neventually periodic sequence. - _Bryle Morga_, Mar 31 2025\n\nHere the $k$-th prime factor of $a(n)$ is the $k$-th smallest distinct prime divisor of\n$|a(n)|$; for example the second prime factors of $a(5) = 18$, $a(6) = 20$ and $a(7) = 896$\nare $3$, $5$ and $7$.\n\nThis was proved by Terence Tao in a [MathOverflow answer](https://mathoverflow.net/a/490348),\nusing that $a(n)$ divides $a(n+3)$ for all $n$.\nLean formalization by Wentao Li, with AI assistance.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at \"https://github.com/VictorLiwentao/lean-oeis-proofs/blob/0a23974e54b90afd1453ef02c27cf8f617bad940/LeanOeisProofs/NewFormalization/A382590.lean#L201\"]\ntheorem kthPrimeFactor_periodic : ∀ k : ℕ, k ≥ 2 → ∃ N₀ p : ℕ, p > 0 ∧\n    ∀ n : ℕ, n ≥ N₀ → kthPrimeFactor k (a (n + p)) = kthPrimeFactor k (a n) := by\n    sorry\n\nend OeisA382590\n",
  "statement_hash": "6485d3b88b4e7cce6145eb2c5a70b7473337eda1ceb1d33ea6bc1de0b08a74f0",
  "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."
}