{
  "id": "5005",
  "ident": "NS.05005",
  "slug": "oeis-166944",
  "title": "Rowland-style prime-generating recurrence",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Conjecture: Every record of differences $a(n)-a(n-1)$ more than 5 is the greater of twin primes\n(A006512).",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA166944.conjecture",
  "statement_lean": "theorem conjecture (R : ℕ) (hR : 5 < R) (hrec : IsDifferenceRecord R) :\n    IsGreaterTwinPrime R",
  "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-style prime-generating recurrence\n\nThe sequence is defined by $a(1) = 2$ and for $n \\ge 2$:\n$a(n) = a(n-1) + \\gcd(n, a(n-1))$ if $n$ is even, and\n$a(n) = a(n-1) + \\gcd(n-2, a(n-1))$ if $n$ is odd.\n\n*References:*\n- [A166944](https://oeis.org/A166944)\n- E. S. Rowland, \"A natural prime-generating recurrence\", *J. Integer Sequences* **11** (2008),\n  Article 08.2.8.\n- V. Shevelev, \"An infinite set of generators of primes based on the Rowland idea and\n  conjectures concerning twin primes\", arXiv preprint\n  [arXiv:0910.4676](https://arxiv.org/abs/0910.4676) [math.NT], 2009.-/\n\n@[expose] public section\n\nnamespace OeisA166944\n\n/-- Defining recurrence for $a(n)$. -/\ndef a : ℕ → ℕ\n  | 0 => 0\n  | 1 => 2\n  | n + 2 =>\n    let prev := a (n + 1)\n    let idx := n + 2\n    if idx % 2 = 0 then prev + Nat.gcd idx prev\n    else prev + Nat.gcd (idx - 2) prev\n\n/-- Value of the sequence `a` at 1. -/\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 2 := by decide\n\n/-- Value of the sequence `a` at 2. -/\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 4 := by decide\n\n/-- Value of the sequence `a` at 3. -/\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 5 := by decide\n\n/-- Value of the sequence `a` at 4. -/\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 6 := by decide\n\n/-- Value of the sequence `a` at 5. -/\n@[category test, AMS 11]\ntheorem a_5 : a 5 = 9 := by decide\n\n/-- The difference sequence $d(n) = a(n) - a(n-1)$ for $n \\ge 2$. -/\ndef d (n : ℕ) : ℕ := a n - a (n - 1)\n\n/-- A prime $p$ is the greater of a twin prime pair if $p$ and $p - 2$ are both prime. -/\ndef IsGreaterTwinPrime (p : ℕ) : Prop := p.Prime ∧ (p - 2).Prime\n\n/--\nA value $R$ is a difference record if there exists $n \\ge 2$ such that $d(n) = R$ and $R$\nis strictly larger than all previous differences $d(k)$ for $2 \\le k < n$.-/\ndef IsDifferenceRecord (R : ℕ) : Prop :=\n  ∃ n : ℕ, 2 ≤ n ∧ d n = R ∧ ∀ k : ℕ, 2 ≤ k → k < n → d k < R\n\n/--\nConjecture: Every record of differences $a(n)-a(n-1)$ more than 5 is the greater of twin primes\n(A006512).-/\n@[category research open, AMS 11]\ntheorem conjecture (R : ℕ) (hR : 5 < R) (hrec : IsDifferenceRecord R) :\n    IsGreaterTwinPrime R := by\n  sorry\n\nend OeisA166944\n",
  "statement_hash": "45bcd7950ca806b86c258221b98a44e62cfabebfac23d494120d48eaee910b5e",
  "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."
}