login
If (p1,p2) is the n-th twin prime pair and p the prime before p1 and q the prime after p2 then a(n) = p + q - (p1 + p2).
0

%I #19 Jul 03 2018 11:27:20

%S 1,2,0,0,0,0,0,2,0,0,4,-4,4,-6,8,0,4,0,6,0,-6,0,-4,0,6,0,0,8,-6,6,-2,

%T -6,6,0,0,4,-4,0,-4,0,-12,0,-14,0,0,-6,0,2,-6,0,-2,0,20,6,-2,8,0,6,-2,

%U 6,0,0,-8,6,4,-10,6,-12,-12,10,0,2,0,4,-6,0,2,0,-6,12,22,-18,6,8,-18,8,-22,6,-2,6,0,0,18,-6

%N If (p1,p2) is the n-th twin prime pair and p the prime before p1 and q the prime after p2 then a(n) = p + q - (p1 + p2).

%F a(n) = A000040(A029707(n)-1) + A000040(A107770(n)+1) - (A001359(n) + A006512(n)). - _Jianing Song_, Jun 22 2018

%e For n = 8, the 8th prime pair is (71, 73), the prime before 71 is 67 and prime after 73 is 79. So a(8) = 67 + 79 - 71 - 73 = 2.

%t Map[#1 + #4 - (#2 + #3) & @@ # &, Select[Partition[Prime@ Range[500], 4, 1], And[#3 - #2 == 2] & @@ # &]] (* _Michael De Vlieger_, Jun 30 2018 *)

%o (PARI) {

%o print1(2+7-(5+3)", ");

%o forstep(n=6,100,6,

%o if(isprime(n-1)&&isprime(n+1),

%o a=precprime(n-2);b=nextprime(n+2);

%o print1(a+b-2*n", ")

%o )

%o )

%o }

%Y Cf. A001097, A054735, A036263.

%K sign,easy

%O 1,2

%A _Dimitris Valianatos_, Jun 21 2018

%E Definition clarified by _Jianing Song_, Jun 22 2018