A255229 Integers n such that n^2 - 1 is the difference of the squares of twin primes.
5, 7, 11, 13, 17, 31, 41, 43, 49, 77, 83, 101, 109, 119, 133, 179, 203, 263, 277, 283, 307, 311, 329, 353, 377, 407, 413, 419, 431, 437, 463, 473, 493, 577, 581, 619, 629, 703, 757, 791, 811, 907, 911, 913, 991, 1001, 1037, 1061, 1103, 1121, 1249, 1289, 1337, 1373, 1441, 1457, 1487, 1523, 1597, 1651, 1781
Offset: 1
Keywords
Examples
31^2 - 1 = 241^2 - 239^2, and (239, 241) is a twin prime pair, so 31 is in the sequence.
Programs
-
Mathematica
lst={};f[n_]:=Sqrt[Prime[n]^2-NextPrime[Prime[n],-1]^2+1]; Do[If[Prime[n]-NextPrime[Prime[n],-1]==2&&IntegerQ[f[n]],AppendTo[lst,f[n]]],{n,3,10^5}];lst (* Ivan N. Ianakiev, Mar 30 2015 *)
-
PARI
lista(nn) = {forprime(p=3, nn, q = precprime(p-1); if (((p-q) == 2) && issquare(d=p^2-q^2+1), print1(sqrtint(d), ", ")); ); } \\ Michel Marcus, Feb 18 2015