/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import FormalConjecturesUtil

Number of primes $p < n$ with $\text{prime}(p)^2 + (\text{prime}(n) - 1)^2$ prime

The sequence $a(n)$ counts the number of primes $p < n$ such that $\text{prime}(p)^2 + (\text{prime}(n) - 1)^2$ is prime, where $\text{prime}(i)$ denotes the $i$-th prime number (1-indexed).

References:

@[expose] public sectionnamespace OeisA238585open Finset

Number of primes $p < n$ with $\text{prime}(p)^2 + (\text{prime}(n) - 1)^2$ prime.

noncomputable def a (n : ℕ) : ℕ := ∑ p ∈ Ico 1 n, if p.Prime ∧ Nat.Prime (Nat.nth Nat.Prime (p - 1) ^ 2 + (Nat.nth Nat.Prime (n - 1) - 1) ^ 2) then 1 else 0@[category test, AMS 11] theorem a_1 : a 1 = 0 := ⊢ a 1 = 0 All goals completed! 🐙@[category test, AMS 11] theorem a_2 : a 2 = 0 := ⊢ a 2 = 0 ⊢ (if Nat.Prime 1 ∧ Nat.Prime (Nat.nth Nat.Prime (1 - 1) ^ 2 + (Nat.nth Nat.Prime (2 - 1) - 1) ^ 2) then 1 else 0) = 0 All goals completed! 🐙@[category test, AMS 11] theorem a_3 : a 3 = 0 := ⊢ a 3 = 0 ⊢ ((if Nat.Prime 1 ∧ Nat.Prime (Nat.nth Nat.Prime 0 ^ 2 + 4 ^ 2) then 1 else 0) + if Nat.Prime 2 ∧ Nat.Prime (3 ^ 2 + 4 ^ 2) then 1 else 0) = 0 All goals completed! 🐙@[category test, AMS 11] theorem a_4 : a 4 = 1 := ⊢ a 4 = 1 ⊢ (if Nat.Prime 1 ∧ Nat.Prime (Nat.nth Nat.Prime 0 ^ 2 + 6 ^ 2) then 1 else 0) + ((if Nat.Prime 2 ∧ Nat.Prime (3 ^ 2 + 6 ^ 2) then 1 else 0) + if Nat.Prime 3 ∧ Nat.Prime (5 ^ 2 + 6 ^ 2) then 1 else 0) = 1 All goals completed! 🐙@[category test, AMS 11] theorem a_5 : a 5 = 1 := ⊢ a 5 = 1 ⊢ (if Nat.Prime 1 ∧ Nat.Prime (Nat.nth Nat.Prime 0 ^ 2 + 10 ^ 2) then 1 else 0) + ((if Nat.Prime 2 ∧ Nat.Prime (3 ^ 2 + 10 ^ 2) then 1 else 0) + ((if Nat.Prime 3 ∧ Nat.Prime (5 ^ 2 + 10 ^ 2) then 1 else 0) + if Nat.Prime 4 ∧ Nat.Prime (Nat.nth Nat.Prime 3 ^ 2 + 10 ^ 2) then 1 else 0)) = 1 All goals completed! 🐙hIco:Ico 1 8 = {1, 2, 3, 4, 5, 6, 7}⊢ a 8 = 2 hIco:Ico 1 8 = {1, 2, 3, 4, 5, 6, 7}⊢ (if Nat.Prime 1 ∧ Nat.Prime (Nat.nth Nat.Prime 0 ^ 2 + 18 ^ 2) then 1 else 0) + ((if Nat.Prime 2 ∧ Nat.Prime (3 ^ 2 + 18 ^ 2) then 1 else 0) + ((if Nat.Prime 3 ∧ Nat.Prime (5 ^ 2 + 18 ^ 2) then 1 else 0) + ((if Nat.Prime 4 ∧ Nat.Prime (Nat.nth Nat.Prime 3 ^ 2 + 18 ^ 2) then 1 else 0) + ((if Nat.Prime 5 ∧ Nat.Prime (11 ^ 2 + 18 ^ 2) then 1 else 0) + ((if Nat.Prime 6 ∧ Nat.Prime (Nat.nth Nat.Prime 5 ^ 2 + 18 ^ 2) then 1 else 0) + if Nat.Prime 7 ∧ Nat.Prime (17 ^ 2 + 18 ^ 2) then 1 else 0))))) = 2 All goals completed! 🐙

Conjecture (i): $a(n) > 0$ unless $n$ divides $6$.

@[category research open, AMS 11] theorem conjecture_1 (n : ℕ) (hn : 0 < n) : 0 < a n ↔ ¬(n ∣ 6) := n:ℕhn:0 < n⊢ 0 < a n ↔ ¬n ∣ 6 All goals completed! 🐙

Conjecture (i): $a(n) = 1$ only for $n \in {4, 5, 7, 10, 11, 12, 19, 21, 22, 31, 42, 44}$.

@[category research open, AMS 11] theorem conjecture_2 (n : ℕ) (hn : 0 < n) : a n = 1 ↔ n ∈ ({4, 5, 7, 10, 11, 12, 19, 21, 22, 31, 42, 44} : Set ℕ) := n:ℕhn:0 < n⊢ a n = 1 ↔ n ∈ {4, 5, 7, 10, 11, 12, 19, 21, 22, 31, 42, 44} All goals completed! 🐙

Conjecture (ii): If $n > 2$ is not equal to $9$, then $\text{prime}(n)^2 + (\text{prime}(p) - 1)^2$ is prime for some prime $p < n$.

@[category research open, AMS 11] theorem conjecture_3 (n : ℕ) (hn : 2 < n) (hn9 : n ≠ 9) : ∃ p : ℕ, p < n ∧ p.Prime ∧ Nat.Prime (Nat.nth Nat.Prime (n - 1) ^ 2 + (Nat.nth Nat.Prime (p - 1) - 1) ^ 2) := n:ℕhn:2 < nhn9:n ≠ 9⊢ ∃ p < n, Nat.Prime p ∧ Nat.Prime (Nat.nth Nat.Prime (n - 1) ^ 2 + (Nat.nth Nat.Prime (p - 1) - 1) ^ 2) All goals completed! 🐙

Conjecture (iii), part 1: For $n > 3$, there is a prime $p < n$ with $\text{prime}(p) + \text{prime}(n) + 1$ prime.

@[category research open, AMS 11] theorem conjecture_4 (n : ℕ) (hn : 3 < n) : ∃ p : ℕ, p < n ∧ p.Prime ∧ Nat.Prime (Nat.nth Nat.Prime (p - 1) + Nat.nth Nat.Prime (n - 1) + 1) := n:ℕhn:3 < n⊢ ∃ p < n, Nat.Prime p ∧ Nat.Prime (Nat.nth Nat.Prime (p - 1) + Nat.nth Nat.Prime (n - 1) + 1) All goals completed! 🐙

Conjecture (iii), part 2: If $n > 9$ is not equal to $18$, then $\text{prime}(p)^2 + \text{prime}(n)^2 - 1$ is prime for some prime $p < n$.

@[category research open, AMS 11] theorem conjecture_5 (n : ℕ) (hn : 9 < n) (hn18 : n ≠ 18) : ∃ p : ℕ, p < n ∧ p.Prime ∧ Nat.Prime (Nat.nth Nat.Prime (p - 1) ^ 2 + Nat.nth Nat.Prime (n - 1) ^ 2 - 1) := n:ℕhn:9 < nhn18:n ≠ 18⊢ ∃ p < n, Nat.Prime p ∧ Nat.Prime (Nat.nth Nat.Prime (p - 1) ^ 2 + Nat.nth Nat.Prime (n - 1) ^ 2 - 1) All goals completed! 🐙end OeisA238585