/-
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 FormalConjecturesUtilSum of next $n$ primes
The sum of the primes in the $n$-th row of the prime number triangle: $$a(n) = \sum_{i = 1 + n(n-1)/2}^{n + n(n-1)/2} p_i$$ with $a(0) = 0$.
References:
namespace OeisA7468Sum of the next $n$ primes, with $a(0) = 0$.
noncomputable def a (n : ℕ) : ℕ :=
let startIdx : ℕ := (n * (n - 1)) / 2
∑ i ∈ Finset.range n, Nat.nth Nat.Prime (startIdx + i)
Value of the sequence a at 0.
@[category test, AMS 11]
theorem a_0 : a 0 = 0 := ⊢ a 0 = 0 All goals completed! 🐙
Value of the sequence a at 1.
All goals completed! 🐙
Value of the sequence a at 2.
@[category test, AMS 11]
theorem a_2 : a 2 = 8 := by ⊢ a 2 = 8
dsimp [a] ⊢ ∑ i ∈ Finset.range 2, Nat.nth Nat.Prime (1 + i) = 8
rw [Finset.sum_range_succ, ⊢ ∑ x ∈ Finset.range 1, Nat.nth Nat.Prime (1 + x) + Nat.nth Nat.Prime (1 + 1) = 8 All goals completed! 🐙 Finset.sum_range_one, ⊢ Nat.nth Nat.Prime (1 + 0) + Nat.nth Nat.Prime (1 + 1) = 8 All goals completed! 🐙 add_zero, ⊢ Nat.nth Nat.Prime 1 + Nat.nth Nat.Prime (1 + 1) = 8 All goals completed! 🐙 Nat.nth_prime_one_eq_three, ⊢ 3 + Nat.nth Nat.Prime (1 + 1) = 8 All goals completed! 🐙
show (1 + 1 : ℕ) = 2 by ⊢ a 2 = 8 All goals completed! 🐙 rfl All goals completed! 🐙 All goals completed! 🐙, Nat.nth_prime_two_eq_five ⊢ 3 + 5 = 8 All goals completed! 🐙] All goals completed! 🐙
Value of the sequence a at 3.
@[category test, AMS 11]
theorem a_3 : a 3 = 31 := by ⊢ a 3 = 31
dsimp [a] ⊢ ∑ i ∈ Finset.range 3, Nat.nth Nat.Prime (3 + i) = 31
have h5 : Nat.nth Nat.Prime 5 = 13 := Nat.nth_count (by ⊢ Nat.Prime 13 h5:Nat.nth Nat.Prime 5 = 13⊢ ∑ i ∈ Finset.range 3, Nat.nth Nat.Prime (3 + i) = 31 decide All goals completed! 🐙 h5:Nat.nth Nat.Prime 5 = 13⊢ ∑ i ∈ Finset.range 3, Nat.nth Nat.Prime (3 + i) = 31 : Nat.Prime 13) h5:Nat.nth Nat.Prime 5 = 13⊢ ∑ i ∈ Finset.range 3, Nat.nth Nat.Prime (3 + i) = 31
rw [Finset.sum_range_succ, h5:Nat.nth Nat.Prime 5 = 13⊢ ∑ x ∈ Finset.range 2, Nat.nth Nat.Prime (3 + x) + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙 Finset.sum_range_succ, h5:Nat.nth Nat.Prime 5 = 13⊢ ∑ x ∈ Finset.range 1, Nat.nth Nat.Prime (3 + x) + Nat.nth Nat.Prime (3 + 1) + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙 Finset.sum_range_one, h5:Nat.nth Nat.Prime 5 = 13⊢ Nat.nth Nat.Prime (3 + 0) + Nat.nth Nat.Prime (3 + 1) + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙 add_zero, h5:Nat.nth Nat.Prime 5 = 13⊢ Nat.nth Nat.Prime 3 + Nat.nth Nat.Prime (3 + 1) + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙
Nat.nth_prime_three_eq_seven, h5:Nat.nth Nat.Prime 5 = 13⊢ 7 + Nat.nth Nat.Prime (3 + 1) + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙 show (3 + 1 : ℕ) = 4 by ⊢ a 3 = 31 All goals completed! 🐙 rfl All goals completed! 🐙 All goals completed! 🐙, Nat.nth_prime_four_eq_eleven, h5:Nat.nth Nat.Prime 5 = 13⊢ 7 + 11 + Nat.nth Nat.Prime (3 + 2) = 31 All goals completed! 🐙
show (3 + 2 : ℕ) = 5 by ⊢ a 3 = 31 All goals completed! 🐙 rfl All goals completed! 🐙 All goals completed! 🐙, h5 h5:Nat.nth Nat.Prime 5 = 13⊢ 7 + 11 + 13 = 31 All goals completed! 🐙] All goals completed! 🐙The only positive integer $n$ such that $a(n)$ is a perfect square is $n=38$.
Carlos Eduardo Olivieri, Mar 09 2015
@[category research open, AMS 11]
theorem conjecture (n : ℕ) (hn : 0 < n) (hsq : IsSquare (a n)) : n = 38 := by n:ℕhn:0 < nhsq:IsSquare (a n)⊢ n = 38
sorry All goals completed! 🐙end OeisA7468