%I #20 Oct 12 2023 13:38:08
%S 3,23,433,16481,24593,167953,173183,183871,192097,223781,414521,
%T 447743,477857,508951,513473,792983,927803,996019,1034251,1250309,
%U 1285937,2224063,2281003,2456191,2607109,2741561,2773073,3210353,3336209,4206817,4403647,4632161
%N The first of two consecutive primes the sum of which is equal to the sum of two consecutive heptagonal numbers.
%H Chai Wah Wu, <a href="/A298466/b298466.txt">Table of n, a(n) for n = 1..10000</a>
%e 23 is in the sequence because 23+29 (consecutive primes) = 52 = 18+34 (consecutive heptagonal numbers).
%t Module[{hep=Total/@Partition[PolygonalNumber[7,Range[1500]],2,1]},Select[ Partition[Prime[Range[PrimePi[Max[hep]/2]]],2,1],MemberQ[hep,Total[#]]&]][[All,1]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Dec 04 2019 *)
%o (PARI) L=List(); forprime(p=2, 6000000, q=nextprime(p+1); t=p+q; if(issquare(20*t-16, &sq) && (sq-2)%10==0, u=(sq-2)\10; listput(L, p))); Vec(L)
%o (Python)
%o from sympy import prevprime, nextprime
%o A298466_list, n, m = [], 1 ,8
%o while len(A298466_list) < 10000:
%o k = prevprime(m//2)
%o if k + nextprime(k) == m:
%o A298466_list.append(k)
%o n += 1
%o m += 10*n-3 # _Chai Wah Wu_, Jan 19 2018
%Y Cf. A000040, A000566, A061275, A298462, A298463, A298464, A298465.
%K nonn
%O 1,1
%A _Colin Barker_, Jan 19 2018