OFFSET
3,1
COMMENTS
Beginning at prime(2)=3, group all primes into even/odd-indexed pairs, (prime(2n), prime(2n+1)). Then a(prime(2n)) and a(prime(2n+1)) are both equal to 2*A077133(n).
This sequence consists of runs of an even number of consecutive numbers. - David A. Corneth, Dec 18 2018
LINKS
David A. Corneth, Table of n, a(n) for n = 3..10002
FORMULA
a(3) = 2. a(n + 1) = a(n) + 1 for composite n + 1. For prime n + 1, a(n + 1) = a(n) + 1 - (n + 1 - p) where p is the largest prime < (n + 1). - David A. Corneth, Dec 18 2018
EXAMPLE
a(12)=7 because the alternating sum of all consecutive prime gaps for all odd primes less than/equal to 12 is -2+2-4, and 11+(-2+2-4)=7.
a(13)=10 because the alternating sum of all consecutive prime gaps for all odd primes less than/equal to 13 is -2+2-4+2=-2, and 12+(-2+2-4+2)=10.
PROG
(PARI) first(n) = my(res = vector(n), p = 3, sgn = 1, primegap = 0); res[1] = 2; for(i = 2, n, res[i] = res[i-1]+1; if(isprime(i+2), sgn=-sgn; primegap = i+2-p; res[i]+=sgn*primegap; p = i+2)); res \\ David A. Corneth, Dec 18 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Christopher Hohl, Dec 15 2018
STATUS
approved