login
A298465
The first of two consecutive heptagonal numbers the sum of which is equal to the sum of two consecutive primes.
5
1, 18, 403, 16281, 24354, 167314, 172528, 183196, 191407, 223054, 413512, 446688, 476767, 507826, 512343, 791578, 926289, 994456, 1032658, 1248562, 1284147, 2221708, 2278630, 2453716, 2604571, 2738952, 2770443, 3207523, 3333330, 4203577, 4400332, 4628761
OFFSET
1,2
EXAMPLE
18 is in the sequence because 18+34 (consecutive heptagonal numbers) = 52 = 23+29 (consecutive primes).
MATHEMATICA
chcpQ[{a_, b_}]:=Module[{c=(a+b)/2}, NextPrime[c]+ NextPrime[c, -1] ==a+b]; Select[ Partition[PolygonalNumber[7, Range[2000]], 2, 1], chcpQ][[;; , 1]] (* Harvey P. Dale, Mar 14 2023 *)
PROG
(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, (5*u^2-3*u)/2))); Vec(L)
(Python)
from sympy import prevprime, nextprime
A298465_list, n, m = [], 1 , 8
while len(A298465_list) < 10000:
k = prevprime(m//2)
if k + nextprime(k) == m:
A298465_list.append(n*(5*n-3)//2)
n += 1
m += 10*n-3 # Chai Wah Wu, Jan 19 2018
KEYWORD
nonn
AUTHOR
Colin Barker, Jan 19 2018
STATUS
approved