Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #10 Jun 18 2022 14:20:16
%S 3,7,7,3,83,5,23,13,5,3,73,5,3,5,13,5,5,5,5,53,29,3,7,7,7,13,11,3,5,
%T 13,7,5,7,5,7,5,7,89,7,7,47,23,5,17,17,13,89,5,7,19,13,7,31,5,19,13,
%U 13,59,5,29,19,29,23,3,13,5,11,13,7,3,7,5,43,29,23,13,97,11,17,71,11,37,71,23,7
%N a(n) is the least prime p such that the sum of squares of n consecutive primes starting with p is GCD(n,24) times a prime.
%C 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).
%H Robert Israel, <a href="/A354966/b354966.txt">Table of n, a(n) for n = 2..10000</a>
%e 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.
%p P:= select(isprime,[2,seq(i,i=3..10^6,2)]):
%p PS:= map(t -> t^2, P):
%p SPS:= ListTools:-PartialSums(PS): N:= nops(SPS):
%p f:= proc(n) local k,j,t,d;
%p d:= igcd(n,24);
%p for k from 1 to N-n do
%p t:= (SPS[k+n]-SPS[k])/d;
%p if t::integer and isprime(t) then return P[k+1] fi
%p od;
%p -1 # a value of -1 indicates that the list of primes needs to be extended
%p end proc:
%p map(f, [$2..100]);
%o (Python)
%o from math import gcd
%o from sympy import sieve, isprime
%o def A354966(n):
%o a, s = gcd(n,24), sum(sieve[j]**2 for j in range(1,n+1))
%o for i in count(1):
%o (b, c), p = divmod(s,a), sieve[i]
%o if c == 0 and isprime(b):
%o return p
%o s += sieve[i+n]**2-p**2 # _Chai Wah Wu_, Jun 14 2022
%K nonn
%O 2,1
%A _J. M. Bergot_ and _Robert Israel_, Jun 13 2022