/- 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. -/ import FormalConjecturesUtil

Triangular matchstick numbers in the class of prime numbers

$a(n) = \sum_{k = n}^{2n} p_k$, where $p_k$ is the $k$-th prime.

References:

namespace OeisA105720open Nat Finset

The primary defining sequence a. $a(n)$ is the sum of primes from the $n$-th prime to the $2n$-th prime, with $p_1=2$. For $n=0$, we define $a(0) = 0$.

noncomputable def a (n : ) : := if n = 0 then 0 else i Ico (n - 1) (2 * n), Nat.nth Nat.Prime ih1:count Nat.Prime 13 = 5h2:Nat.Prime 13nth Nat.Prime 5 = 13 h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime (count Nat.Prime 13) = 13nth Nat.Prime 5 = 13 rwa [h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime 5 = 13nth Nat.Prime 5 = 13h1:count Nat.Prime 13 = 5h2:Nat.Prime 13h3:nth Nat.Prime 5 = 13nth Nat.Prime 5 = 13 at h3h1:count Nat.Prime 17 = 6h2:Nat.Prime 17nth Nat.Prime 6 = 17 h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime (count Nat.Prime 17) = 17nth Nat.Prime 6 = 17 rwa [h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime 6 = 17nth Nat.Prime 6 = 17h1:count Nat.Prime 17 = 6h2:Nat.Prime 17h3:nth Nat.Prime 6 = 17nth Nat.Prime 6 = 17 at h3h1:count Nat.Prime 19 = 7h2:Nat.Prime 19nth Nat.Prime 7 = 19 h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime (count Nat.Prime 19) = 19nth Nat.Prime 7 = 19 rwa [h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime 7 = 19nth Nat.Prime 7 = 19h1:count Nat.Prime 19 = 7h2:Nat.Prime 19h3:nth Nat.Prime 7 = 19nth Nat.Prime 7 = 19 at h3macro "eval_a" : tactic => `(tactic| ( repeat rw [Finset.sum_Ico_succ_top (by decide)] simp only [Finset.Ico_self, Finset.sum_empty, zero_add, add_zero] simp only [Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three, Nat.nth_prime_two_eq_five, Nat.nth_prime_three_eq_seven, Nat.nth_prime_four_eq_eleven, nth_prime_five, nth_prime_six, nth_prime_seven] try rfl ))

Value of the sequence a at 0.

All goals completed! 🐙

Value of the sequence a at 1.

i Ico (1 - 1) (2 * 1), nth Nat.Prime i = 5 All goals completed! 🐙

Value of the sequence a at 2.

i Ico (2 - 1) (2 * 2), nth Nat.Prime i = 15 All goals completed! 🐙

Value of the sequence a at 3.

i Ico (3 - 1) (2 * 3), nth Nat.Prime i = 36 All goals completed! 🐙

Value of the sequence a at 4.

i Ico (4 - 1) (2 * 4), nth Nat.Prime i = 67 All goals completed! 🐙

Terms are squares at only(?) three values of $n = 3, 6, 4072$: corresponding terms are 6^2, 13^2, and 15735^2.

@[category research open, AMS 11] theorem conjecture : n : , 0 < n (IsSquare (a n) (n = 3 n = 6 n = 4072)) := (n : ), 0 < n (IsSquare (OeisA105720.a n) n = 3 n = 6 n = 4072) All goals completed! 🐙end OeisA105720