%I #30 Sep 19 2022 20:24:00
%S 37,5,283,929,13,696607,531901,408079937,17028422981
%N a(n) is the first prime that starts a string of exactly n consecutive primes where the prime + the next prime + 1 is prime.
%C a(n) is the first prime p(k) such that p(k+i)+p(k+i+1)+1 is prime for i from 0 to n-1, but not for i=-1 or n.
%e a(5) = 13 because 13+17+1 = 31, 17+19+1 = 37, 19+23+1 = 43, 23+29+1 = 53, and 29+31+1 = 61 are prime, but 11+13+1 = 25 and 31+37+1 = 69 are not, and 13 is the first prime that works.
%p P:= select(isprime, [seq(i,i=3..10^6,2)]):
%p V:= Vector(7):
%p state:= 0:
%p for i from 1 to nops(P)-1 do
%p if isprime(P[i]+P[i+1]+1) then
%p state:= state+1
%p else
%p if state > 0 and V[state] = 0 then V[state]:= P[i-state] fi;
%p state:= 0
%p fi
%p od:
%p convert(V,list);
%o (Python)
%o from itertools import count, islice
%o from sympy import isprime, nextprime
%o def f(p):
%o c, p0, p1 = 0, p, nextprime(p)
%o while isprime(p0+p1+1):
%o c, p0, p1 = c+1, p1, nextprime(p1)
%o return c, p1
%o def agen():
%o n, adict, pk = 1, dict(), 2
%o for k in count(1):
%o fk, pk2 = f(pk)
%o if fk not in adict: adict[fk] = pk
%o while n in adict: yield adict[n]; n += 1
%o pk = pk2
%o print(list(islice(agen(), 7))) # _Michael S. Branicky_, Sep 18 2022
%Y Cf. A177017.
%K nonn,more
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, Sep 17 2022
%E a(8)-a(9) from _Michael S. Branicky_, Sep 18 2022
|