login
a(n) is the difference between the sum of the first n even-indexed primes and the sum of the first n odd-indexed primes.
5

%I #32 May 09 2023 09:58:36

%S 1,3,5,7,13,19,21,27,29,33,39,45,49,53,57,61,63,65,71,77,79,81,83,95,

%T 97,103,113,119,121,125,135,139,143,149,151,157,163,167,175,183,185,

%U 187,191,199,201,213,217,221,233,251,261,267,273,279,281,287,289,299

%N a(n) is the difference between the sum of the first n even-indexed primes and the sum of the first n odd-indexed primes.

%C Some odd numbers such as 11, 17, 23 and 25 never appear.

%H Paolo Xausa, <a href="/A077133/b077133.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = Sum_{i=0..n-1} (prime(2*i+2) - prime(2*i+1)).

%F a(n) = A008347(2n). - _Ridouane Oudra_, Aug 31 2019

%F a(n) = A077126(n) - A077131(n). - _Michel Marcus_, Oct 05 2019

%e 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]

%p with(numtheory): A008347 := proc(n) option remember; if n = 0 then 0 else abs(A008347(n-1)-ithprime(n)); fi; end proc:

%p seq(A008347(2n),n=1..80); # _Ridouane Oudra_, Aug 31 2019

%t Table[ Sum[ Prime[2i], {i, 1, n}] - Sum[ Prime[2i - 1], {i, 1, n}], {n, 1, 60}]

%t A077133[nmax_]:=Accumulate[Prime[Range[2,2nmax,2]]-Prime[Range[1,2nmax,2]]];A077133[100] (* _Paolo Xausa_, Apr 12 2023 *)

%o (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, ", ")))

%Y Cf. A008347, A077126, A077131.

%K nonn

%O 1,2

%A _Jon Perry_, Nov 29 2002

%E Edited and extended by _Robert G. Wilson v_, Nov 30 2002

%E Name clarified by _Paolo Xausa_, Apr 12 2023