OFFSET
1,2
COMMENTS
Some odd numbers such as 11, 17, 23 and 25 never appear.
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{i=0..n-1} (prime(2*i+2) - prime(2*i+1)).
a(n) = A008347(2n). - Ridouane Oudra, Aug 31 2019
EXAMPLE
a(2) = 3 as the sum of the first 2 even-indexed primes is prime(2) + prime(4) = 3 + 7 = 10, the sum of the first 2 odd-indexed primes is prime(1) + prime(3) = 2 + 5 = 7 and 10 - 7 = 3. [edited by Paolo Xausa, Apr 12 2023]
MAPLE
with(numtheory): A008347 := proc(n) option remember; if n = 0 then 0 else abs(A008347(n-1)-ithprime(n)); fi; end proc:
seq(A008347(2n), n=1..80); # Ridouane Oudra, Aug 31 2019
MATHEMATICA
Table[ Sum[ Prime[2i], {i, 1, n}] - Sum[ Prime[2i - 1], {i, 1, n}], {n, 1, 60}]
A077133[nmax_]:=Accumulate[Prime[Range[2, 2nmax, 2]]-Prime[Range[1, 2nmax, 2]]]; A077133[100] (* Paolo Xausa, Apr 12 2023 *)
PROG
(PARI) my(pc=1, p1s=0, p2s=0); forprime (p=2, 500, pc=!pc; if (pc, p1s+=p, p2s+=p); if (pc, print1(p1s-p2s, ", ")))
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, Nov 29 2002
EXTENSIONS
Edited and extended by Robert G. Wilson v, Nov 30 2002
Name clarified by Paolo Xausa, Apr 12 2023
STATUS
approved