{
  "id": "8406",
  "ident": "NS.08406",
  "slug": "wikipedia-rowlandsequence",
  "title": "Rowland's GCD prime-generating recurrence",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Rowland's theorem (2008): for every $n \\ge 2$, the step $d(n) = a(n) - a(n - 1)$ equals $1$ or is\nprime.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "RowlandSequence.rowland_diff_eq_one_or_prime",
  "statement_lean": "theorem rowland_diff_eq_one_or_prime {n : ℕ} (hn : 2 ≤ n) :\n    rowlandDiff n = 1 ∨ (rowlandDiff n).Prime",
  "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# Rowland's GCD prime-generating recurrence\n\nDefine $a(1) = 7$ and $a(n) = a(n - 1) + \\gcd(n, a(n - 1))$ for $n \\ge 2$ (`OEIS A106108`), with\nstep increments $d(n) = a(n) - a(n - 1) = \\gcd(n, a(n - 1))$ (`OEIS A132199` lists $d(n + 1)$ for\n$n \\ge 1$). Eric S. Rowland established in 2008 that every $d(n)$ with $n \\ge 2$ equals $1$ or an\nodd prime, and conjectured that every odd prime arises as $d(n)$ for some $n \\ge 2$.\n\n*References:*\n- [Wikipedia](https://en.wikipedia.org/wiki/Formula_for_primes#Rowland%27s_prime-generating_sequence)\n- [OEIS A106108](https://oeis.org/A106108)\n- [OEIS A132199](https://oeis.org/A132199)\n- E. S. Rowland, *A natural prime-generating recurrence*, J. Integer Seq. **11** (2008),\n  Article 08.2.8.\n-/\n\n@[expose] public section\n\nnamespace RowlandSequence\n\n/-- Rowland's sequence (`OEIS A106108`), starting at $a(1) = 7$ with recurrence\n$a(n) = a(n - 1) + \\gcd(n, a(n - 1))$ for $n \\ge 2$ (and $a(0) = 0$). -/\ndef rowlandSeq : ℕ → ℕ\n  | 0 => 0\n  | 1 => 7\n  | n + 2 =>\n    let prev := rowlandSeq (n + 1)\n    prev + Nat.gcd (n + 2) prev\n\n/-- Step increment $d(n) = a(n) - a(n - 1)$ of `rowlandSeq` (meaningful for $n \\ge 2$; shifted by\none from `OEIS A132199`, where `A132199(n) = rowlandDiff (n + 1)`). -/\ndef rowlandDiff (n : ℕ) : ℕ :=\n  rowlandSeq n - rowlandSeq (n - 1)\n\n/-- Checks the initial values $a(1), \\dots, a(6) = 7, 8, 9, 10, 15, 18$ of `rowlandSeq`. -/\n@[category test, AMS 11]\ntheorem rowlandSeq_initial_values :\n    rowlandSeq 1 = 7 ∧ rowlandSeq 2 = 8 ∧ rowlandSeq 3 = 9 ∧\n      rowlandSeq 4 = 10 ∧ rowlandSeq 5 = 15 ∧ rowlandSeq 6 = 18 := by\n  decide\n\n/-- Checks $d(2) = 1$ alongside the odd-prime increments $d(5) = 5$, $d(6) = 3$, and\n$d(11) = 11$. -/\n@[category test, AMS 11]\ntheorem rowlandDiff_small_witnesses :\n    rowlandDiff 2 = 1 ∧ rowlandDiff 5 = 5 ∧ rowlandDiff 6 = 3 ∧ rowlandDiff 11 = 11 := by\n  decide\n\n/--\nRowland's theorem (2008): for every $n \\ge 2$, the step $d(n) = a(n) - a(n - 1)$ equals $1$ or is\nprime.\n-/\n@[category research solved, AMS 11]\ntheorem rowland_diff_eq_one_or_prime {n : ℕ} (hn : 2 ≤ n) :\n    rowlandDiff n = 1 ∨ (rowlandDiff n).Prime := by\n  sorry\n\n/--\nRowland's conjecture (2008): every odd prime $p$ occurs as $d(n) = a(n) - a(n - 1)$ at some index\n$n \\ge 2$. The prime $2$ is excluded because $n$ and $a(n - 1)$ always have opposite parity, and\n$n \\ge 2$ excludes the artifact `rowlandDiff 1 = 7`.\n-/\n@[category research open, AMS 11]\ntheorem rowland_generates_all_odd_primes {p : ℕ} (hp : p.Prime) (hodd : Odd p) :\n    ∃ n : ℕ, 2 ≤ n ∧ rowlandDiff n = p := by\n  sorry\n\nend RowlandSequence\n",
  "statement_hash": "e02ffc70e9ba60085f34b8efad795380fb8c57eec028e074c049b2a454770ca7",
  "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."
}