OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..22054 (terms 1..100 from Harry J. Smith)
FORMULA
EXAMPLE
prime(7) + prime(8) = 17 + 19 = 36 = 6^2.
MATHEMATICA
PrevPrim[n_] := Block[{k = n - 1}, While[ !PrimeQ[k], k-- ]; k]; NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; f[n_] := Block[{m = Floor[n/2]}, s = PrevPrim[m] + NextPrim[m]; If[s == n, True, False]]; Select[ Range[550], f[ #^2] &]^2
t := Table[Prime[n] + Prime[n + 1], {n, 15000}]; Select[t, IntegerQ[Sqrt[#]] &] (* Carlos Eduardo Olivieri, Feb 25 2015 *)
PROG
(PARI) {for(n=1, 100, (p=precprime(n^2/2))+nextprime(p+2) == n^2 && print1(n^2", "))} \\ Zak Seidov, Feb 17 2011
(Python)
from itertools import count, islice
from sympy import nextprime, prevprime
def agen(): # generator of terms
for k in count(4, step=2):
kk = k*k
if prevprime(kk//2+1) + nextprime(kk//2-1) == kk:
yield kk
print(list(islice(agen(), 37))) # Michael S. Branicky, May 24 2022
CROSSREFS
Cf. A080665 (same with sum of three consecutive primes).
KEYWORD
easy,nonn
AUTHOR
Jason Earls, Jul 11 2001
EXTENSIONS
Edited by Robert G. Wilson v, Mar 02 2003
Edited (crossrefs completed, obsolete PARI code deleted) by M. F. Hasler, Jan 03 2020
STATUS
approved