%I #28 Jul 25 2024 02:23:13
%S 2,4,6,9,11,14,16,19,23,25,29,32,34,37,41,45,47,51,54,56,60,63,67,72,
%T 75,77,80,82,85,93,96,100,102,108,110,114,118,121,125,129,131,137,139,
%U 142,144,151,158,161,163,166,170,172,178,182,186,190,192,196,199,201,207,215
%N An alternating sum from the n-th odd number up to the n-th odd prime.
%C Define the alternating sum S(n) = -Sum_{j=0..n} (-1)^j*j = -A130472(n).
%C Then a(n) = S(n-th odd prime) - S((n-th odd number) - 1), as if the sum were ranging over all j from the n-th odd number up to the n-th odd prime.
%H Robert Israel, <a href="/A163057/b163057.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = -A130472(A065091(n)) + A130472(A005408(n-1) - 1).
%F a(n) = (1/2)*(-1 + 2n + A000040(n + 1)). - _David Trimas_, Jul 21 2024
%e a(1) = 1 - 2 + 3 = 2;
%e a(2) = 3 - 4 + 5 = 4;
%e a(3) = 5 - 6 + 7 = 6;
%e a(4) = 7 - 8 + 9 - 10 + 11 = 9;
%e a(5) = 9 - 10 + 11 - 12 + 13 = 11;
%e a(6) = 11 - 12 + 13 - 14 + 15 - 16 + 17 = 14.
%p A130472 := proc(n) (-1)^n*floor((n+1)/2) ; end:
%p A005408 :=proc(n) 2*n+1 ; end:
%p A065091 :=proc(n) ithprime(n+1) ; end:
%p A163057 := proc(n) -A130472(A065091(n)) + A130472(A005408(n-1) -1) ; end: seq(A163057(n),n=1..80) ; # _R. J. Mathar_, Jul 27 2009
%t 1/2 (-1 + 2 # + Prime[# + 1]) & /@ Range[100] (* _David Trimas_, Jul 21 2024 *)
%o (Python)
%o from sympy import sieve as A000040
%o def A163057(n): return n + A000040[n + 1] // 2 # _Karl-Heinz Hofmann_, Jul 23 2024
%Y Cf. A000040, A065091, A005408, A130472.
%K nonn,easy
%O 1,1
%A _Juri-Stepan Gerasimov_, Jul 20 2009
%E Rephrased in terms of A130472 by _R. J. Mathar_, Jul 27 2009
|