A353073 Numbers that differ from their prime neighbors by a square.
4, 6, 12, 18, 30, 42, 60, 72, 93, 102, 108, 138, 140, 148, 150, 180, 182, 190, 192, 198, 228, 240, 242, 250, 270, 282, 284, 292, 312, 338, 346, 348, 363, 393, 405, 410, 418, 420, 422, 430, 432, 453, 462, 483, 495, 522, 532, 548, 556, 570, 578, 586, 600, 618
Offset: 1
Keywords
Examples
Prime neighbors of 93 are 89 and 97, they both differ from 93 by 4, a square. Thus, 93 is in this sequence. Prime neighbors of 140 are 149 and 139. They differ from 140 by 9 and 1, respectively. Both differences are squares, thus, 140 is in this sequence.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A353072.
Programs
-
Maple
q:= n-> andmap(issqr, [n-prevprime(n), nextprime(n)-n]): select(q, [$3..700])[]; # Alois P. Heinz, Apr 22 2022
-
Mathematica
Select[Range[3, 2000], IntegerQ[Sqrt[NextPrime[#] - #]] && IntegerQ[Sqrt[# - Prime[PrimePi[NextPrime[# - 1]] - 1]]] &]
-
PARI
isok(k) = (k>1) && issquare(nextprime(k+1)-k) && issquare(k-precprime(k-1)); \\ Michel Marcus, Apr 22 2022
-
Python
from itertools import islice, count from sympy import integer_nthroot, nextprime, prevprime def A353073_gen(startvalue=3): # generator of terms >= startvalue q = nextprime(max(startvalue,3)-1) p, r = prevprime(q), nextprime(q) while True: if integer_nthroot(q-p,2)[1] and integer_nthroot(r-q,2)[1]: yield q t = q for i in count(1): t += 2*i-1 if t >= r: break if integer_nthroot(r-t,2)[1]: yield t p, q, r = q, r, nextprime(r) A353073_list = list(islice(A353073_gen(),30)) # Chai Wah Wu, Apr 22 2022
Comments