{
  "id": "6479",
  "ident": "NS.06479",
  "slug": "oeis-38771--conjecture2",
  "title": "Smallest composite $c$ such that $\\textrm{primorial}(n) + c$ is prime · conjecture2",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "All the terms in this sequence have exactly two prime factors.\nThis conjecture is true for the first 133 terms.\n- [Dmitry Kamenetsky](https://oeis.org/wiki/User:Dmitry_Kamenetsky), Jan 06 2019",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA38771.conjecture2",
  "statement_lean": "theorem conjecture2 (n : ℕ) : (a n).IsSemiprime",
  "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/-!\n# Smallest composite $c$ such that $\\textrm{primorial}(n) + c$ is prime\n\n*References:*\n- [A038771](https://oeis.org/A038771)\n-/\n\n@[expose] public section\n\nopen Filter Topology Real\n\n\n\nnamespace OeisA38771\n\n/-- $a(n)$ is the smallest composite number $c$ such that $\\textrm{primorial}(n) + c$ is prime. -/\nnoncomputable def a (n : ℕ) : ℕ :=\n  let Qn : ℕ := ∏ i ∈ Finset.range n, Nat.nth Nat.Prime i\n  let is_composite (c : ℕ) : Prop := c > 1 ∧ ¬ c.Prime\n  sInf { c : ℕ | is_composite c ∧ (Qn + c).Prime }\n\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 4 := by\n  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧\n    ((∏ i ∈ Finset.range 0, Nat.nth Nat.Prime i) + c).Prime } = 4\n  have hQ : (∏ i ∈ Finset.range 0, Nat.nth Nat.Prime i) = 1 := by rfl\n  rw [hQ]\n  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (1 + c).Prime } 4 := by\n    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩\n    intro c hc\n    by_contra! hlt\n    interval_cases c <;> revert hc <;> decide\n  exact h_least.csInf_eq\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 9 := by\n  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧\n    ((∏ i ∈ Finset.range 1, Nat.nth Nat.Prime i) + c).Prime } = 9\n  have hQ : (∏ i ∈ Finset.range 1, Nat.nth Nat.Prime i) = 2 := by\n    rw [Finset.prod_range_one, Nat.nth_prime_zero_eq_two]\n  rw [hQ]\n  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (2 + c).Prime } 9 := by\n    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩\n    intro c hc\n    by_contra! hlt\n    interval_cases c <;> revert hc <;> decide\n  exact h_least.csInf_eq\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 25 := by\n  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧\n    ((∏ i ∈ Finset.range 2, Nat.nth Nat.Prime i) + c).Prime } = 25\n  have hQ : (∏ i ∈ Finset.range 2, Nat.nth Nat.Prime i) = 6 := by\n    rw [Finset.prod_range_succ, Finset.prod_range_one,\n      Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three]\n    rfl\n  rw [hQ]\n  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (6 + c).Prime } 25 := by\n    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩\n    intro c hc\n    by_contra! hlt\n    interval_cases c <;> revert hc <;> decide\n  exact h_least.csInf_eq\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 49 := by\n  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧\n    ((∏ i ∈ Finset.range 3, Nat.nth Nat.Prime i) + c).Prime } = 49\n  have hQ : (∏ i ∈ Finset.range 3, Nat.nth Nat.Prime i) = 30 := by\n    rw [Finset.prod_range_succ, Finset.prod_range_succ, Finset.prod_range_one,\n      Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three, Nat.nth_prime_two_eq_five]\n    rfl\n  rw [hQ]\n  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (30 + c).Prime } 49 := by\n    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩\n    intro c hc\n    by_contra! hlt\n    interval_cases c <;> revert hc <;> decide\n  exact h_least.csInf_eq\n\n/--\n$a(n) \\ne 0$ for all $n$ (i.e., a suitable composite $c$ always exists).\nThe following more general statement follows from Dirichlet's theorem\non primes in arithmetic progressions:\n  there doesn't exist a > 0 natural number such that p - a is prime for every prime p > a.\n\nChoose q prime such that q is coprime with a, and p > a + q prime such that q | p - a\n(such a p exists from Dirichlet's theorem). Then p - a is composite, a contradiction.\n-/\n@[category textbook, AMS 11]\ntheorem a_n_exists (n : ℕ) : a n ≠ 0 := by\n  unfold a\n  set Q : ℕ := ∏ i ∈ Finset.range n, Nat.nth Nat.Prime i with hQdef\n  have hQ : 0 < Q := Finset.prod_pos fun i _ => (Nat.prime_nth_prime i).pos\n  -- A prime `q > Q` is coprime to `Q`.\n  obtain ⟨q, hqQ, hq⟩ := Nat.exists_infinite_primes (Q + 1)\n  have : NeZero q := ⟨hq.ne_zero⟩\n  have hunit : IsUnit (Q : ZMod q) := by\n    rw [ZMod.isUnit_iff_coprime]\n    exact ((Nat.Prime.coprime_iff_not_dvd hq).2 (Nat.not_dvd_of_pos_of_lt hQ (by omega))).symm\n  -- By Dirichlet there is a prime `p > Q + q` with `p ≡ Q (mod q)`; then `c = p - Q` is composite.\n  obtain ⟨p, hp, hpp, hpq⟩ := Nat.forall_exists_prime_gt_and_eq_mod hunit (Q + q)\n  have hdvd : q ∣ p - Q := by\n    have h := (ZMod.natCast_eq_natCast_iff p Q q).1 hpq\n    exact (Nat.modEq_iff_dvd' (by omega)).1 h.symm\n  have hmem : p - Q ∈ {c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (Q + c).Prime} := by\n    refine ⟨⟨by omega, Nat.not_prime_of_dvd_of_lt hdvd hq.two_le (by omega)⟩, ?_⟩\n    rwa [Nat.add_sub_cancel' (by omega : Q ≤ p)]\n  have := Nat.sInf_mem ⟨_, hmem⟩\n  exact fun h0 => by rw [h0] at this; exact absurd this.1.1 (by norm_num)\n\n/--\nConjecture:\n$\\liminf_{n \\to \\infty} \\frac{a(n)}{p_{n+1}^2} = 1 <$\n$\\limsup_{n \\to \\infty} \\frac{a(n)}{p_{n+1}^2} = 2$.\n- Charles R Greathouse IV and Thomas Ordowski, Apr 24 2015\n-/\n@[category research open, AMS 11]\ntheorem conjecture1 :\n    let p_next_sq (n : ℕ) : ℝ := ((Nat.nth Nat.Prime n : ℝ)) ^ 2\n    let seq (n : ℕ) : ℝ := (a n : ℝ) / p_next_sq n\n    (liminf seq atTop = 1) ∧ (limsup seq atTop = 2) := by\n  sorry\n\n/--\nAll the terms in this sequence have exactly two prime factors.\nThis conjecture is true for the first 133 terms.\n- [Dmitry Kamenetsky](https://oeis.org/wiki/User:Dmitry_Kamenetsky), Jan 06 2019\n-/\n@[category research open, AMS 11]\ntheorem conjecture2 (n : ℕ) : (a n).IsSemiprime := by\n  sorry\n\nend OeisA38771\n",
  "statement_hash": "0a534a107f3a34e48e33b5844c97ff1b3b20ce8a5c3b11f8e2c90f02da7d86d1",
  "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."
}