A353072 Numbers k such that nextprime(k)-k is a positive square.
1, 2, 4, 6, 7, 10, 12, 13, 16, 18, 19, 22, 25, 28, 30, 33, 36, 37, 40, 42, 43, 46, 49, 52, 55, 58, 60, 63, 66, 67, 70, 72, 75, 78, 79, 82, 85, 88, 93, 96, 97, 100, 102, 103, 106, 108, 109, 112, 118, 123, 126, 127, 130, 133, 136, 138, 140, 145, 148, 150, 153
Offset: 1
Keywords
Examples
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.
Links
- David A. Corneth, Table of n, a(n) for n = 1..10000
Programs
-
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 *)
-
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
Comments