login
a(n) is the first prime p such that the sum of 2*n consecutive primes starting at p is q*(q+1) where q is prime, or 0 if there is no such p.
2

%I #11 Dec 21 2020 12:50:40

%S 5,71,3,977,37,7829,8681,283,14341,37181,31,8839,1181,60901,54727,

%T 2579,64901,1248019,43,141803,47,29881,991,5,881,1603919,31123,18679,

%U 174149,74149,11,1328269,925513,447859,61,890969,5867,35759,4093,27239,1549,6551,1901987,4597,64781,307,13121,353

%N a(n) is the first prime p such that the sum of 2*n consecutive primes starting at p is q*(q+1) where q is prime, or 0 if there is no such p.

%H Robert Israel, <a href="/A338989/b338989.txt">Table of n, a(n) for n = 1..141</a>

%e a(3) = 3 because the sum of the 2*3=6 consecutive primes starting at 3 is 3+5+7+11+13+17 = 56 = 7*(7+1) where 7 is prime.

%e a(4) = 977 because the sum of the 2*4=8 consecutive primes starting at 977 is 977+983+991+997+1009+1013+1019+1021 = 8010 = 89*(89+1) where 89 is prime.

%p N:= 10^5:

%p P:= select(isprime, [2, seq(i, i=3..N, 2)]):

%p S:= ListTools:-PartialSums([0, op(P)]):

%p nP:= nops(S):

%p f:= proc(n) local i;

%p for i from 1 to nP-n do

%p if issqr(1+4*(S[i+n]-S[i])) and isprime((sqrt(1+4*(S[i+n]-S[i]))-1)/2)then return P[i] fi

%p od;

%p FAIL

%p end proc:

%p R:= NULL:

%p for i from 1 do

%p v:= f(2*i);

%p if v = FAIL then break fi;

%p R:= R, v

%p od:

%p R;

%Y Cf. A338985, A338990.

%K nonn

%O 1,1

%A _J. M. Bergot_ and _Robert Israel_, Dec 20 2020