|
|
A318789
|
|
For n >= 3, a(n) is equal to n-1 plus the alternating sum of all consecutive prime gaps between odd primes <= n.
|
|
1
|
|
|
2, 3, 2, 3, 6, 7, 8, 9, 6, 7, 10, 11, 12, 13, 10, 11, 14, 15, 16, 17, 14, 15, 16, 17, 18, 19, 26, 27, 26, 27, 28, 29, 30, 31, 38, 39, 40, 41, 38, 39, 42, 43, 44, 45, 42, 43, 44, 45, 46, 47, 54, 55, 56, 57, 58, 59, 54, 55, 58, 59, 60, 61, 62, 63, 58, 59, 60, 61, 66, 67, 66, 67, 68
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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
|
|
|
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
|
|
|
STATUS
|
approved
|
|
|
|