OFFSET
2,1
COMMENTS
Since p^2 == 1 (mod 24) for all primes p > 3, the sum of n squares of such primes is congruent to n (mod 24) and thus divisible by GCD(n,24).
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
EXAMPLE
a(4) = 7 because the sum of squares of 4 consecutive primes starting with 7 is 7^2+11^2+13^2+17^2 = 628 = 4*157 where GCD(4,24) = 4, and 157 is prime, and 7 is the least prime that works: 2^2+3^2+5^2+7^2 = 3*29, 3^2+5^2+7^2+11^2 = 4*3*17, and 5^2+7^2+11^2+13^2 = 4*7*13.
MAPLE
P:= select(isprime, [2, seq(i, i=3..10^6, 2)]):
PS:= map(t -> t^2, P):
SPS:= ListTools:-PartialSums(PS): N:= nops(SPS):
f:= proc(n) local k, j, t, d;
d:= igcd(n, 24);
for k from 1 to N-n do
t:= (SPS[k+n]-SPS[k])/d;
if t::integer and isprime(t) then return P[k+1] fi
od;
-1 # a value of -1 indicates that the list of primes needs to be extended
end proc:
map(f, [$2..100]);
PROG
(Python)
from math import gcd
from sympy import sieve, isprime
def A354966(n):
a, s = gcd(n, 24), sum(sieve[j]**2 for j in range(1, n+1))
for i in count(1):
(b, c), p = divmod(s, a), sieve[i]
if c == 0 and isprime(b):
return p
s += sieve[i+n]**2-p**2 # Chai Wah Wu, Jun 14 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Jun 13 2022
STATUS
approved