cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A356745 a(n) is the first prime that starts a string of exactly n consecutive primes where the prime + the next prime + 1 is prime.

This page as a plain text file.
%I A356745 #30 Sep 19 2022 20:24:00
%S A356745 37,5,283,929,13,696607,531901,408079937,17028422981
%N A356745 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 A356745 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 A356745 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 A356745 P:= select(isprime, [seq(i,i=3..10^6,2)]):
%p A356745 V:= Vector(7):
%p A356745 state:= 0:
%p A356745 for i from 1 to nops(P)-1 do
%p A356745 if isprime(P[i]+P[i+1]+1) then
%p A356745   state:= state+1
%p A356745 else
%p A356745   if state > 0 and V[state] = 0 then V[state]:= P[i-state] fi;
%p A356745   state:= 0
%p A356745 fi
%p A356745 od:
%p A356745 convert(V,list);
%o A356745 (Python)
%o A356745 from itertools import count, islice
%o A356745 from sympy import isprime, nextprime
%o A356745 def f(p):
%o A356745     c, p0, p1 = 0, p, nextprime(p)
%o A356745     while isprime(p0+p1+1):
%o A356745         c, p0, p1 = c+1, p1, nextprime(p1)
%o A356745     return c, p1
%o A356745 def agen():
%o A356745     n, adict, pk = 1, dict(), 2
%o A356745     for k in count(1):
%o A356745         fk, pk2 = f(pk)
%o A356745         if fk not in adict: adict[fk] = pk
%o A356745         while n in adict: yield adict[n]; n += 1
%o A356745         pk = pk2
%o A356745 print(list(islice(agen(), 7))) # _Michael S. Branicky_, Sep 18 2022
%Y A356745 Cf. A177017.
%K A356745 nonn,more
%O A356745 1,1
%A A356745 _J. M. Bergot_ and _Robert Israel_, Sep 17 2022
%E A356745 a(8)-a(9) from _Michael S. Branicky_, Sep 18 2022