A341765 Consider gaps between successive odd primes from 3 up to prime(n+2). Let k1 be number of gaps congruent to 2 (mod 6) and let k2 be number of gaps congruent to 4 (mod 6). Then a(n) = k1 - k2.
1, 2, 1, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2
Offset: 1
Keywords
Examples
a(1)=1 because prime(2+1)-prime(2)=5-3=2 then the gap 2 is congruent to 2 mod 6, then k1=1 and k2=0 so k1 - k2 = 1.
Programs
-
Mathematica
k1 = 0; k2 = 0; cc = {}; Do[ gap = Prime[n + 1] - Prime[n]; If[Mod[gap/2, 3] == 1, k1 = k1 + 1, If[Mod[gap/2, 3] == 2, k2 = k2 + 1]]; AppendTo[cc, k1 - k2]; If[k1 - k2 == 1, , If[k1 - k2 == 2, , Print[{n, k1 - k2}]]], {n, 2, 105}]; cc
-
PARI
a(n) = {my(vp = vector(n+1, k, prime(k+1)), dp = vector(#vp-1, k, (vp[k+1] - vp[k])/2)); my(s=0); for (k=1, #dp, if ((dp[k]%3)==1, s++); if ((dp[k]%3) == 2, s--)); s;} \\ Michel Marcus, Feb 27 2021
Formula
a(n) = 3 - A039701(n+2). - Andrey Zabolotskiy, Nov 04 2024
Extensions
Name edited by Andrey Zabolotskiy, Nov 04 2024
Comments