OFFSET
1,2
COMMENTS
Numbers p-1, where p is prime is a subsequence (see A006093).
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
EXAMPLE
The next prime after 7 is 11, and 11-7 = 4 a square, so 7 is in this sequence.
The next prime after 118 is 127, 127-118 = 9 is a square, so 118 is a term.
MATHEMATICA
Select[Range[2000], NextPrime[#] - # > 0 && IntegerQ[Sqrt[NextPrime[#] - #]] &]
npsQ[n_]:=With[{c=NextPrime[n]-n}, c>0&&IntegerQ[Sqrt[c]]]; Select[Range[200], npsQ] (* Harvey P. Dale, May 05 2023 *)
PROG
(PARI) upto(n) = {my(res = List(1), q = 2, u = nextprime(n + 1)); forprime(p = 3, u, forstep(i = sqrtint(p - q), 1, -1, listput(res, p-i^2) ); q = p ); res } \\ David A. Corneth, Apr 22 2022
(PARI) isok(k) = issquare(nextprime(k+1)-k); \\ Michel Marcus, Apr 22 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Tanya Khovanova, Apr 21 2022
STATUS
approved