login
A163057
An alternating sum from the n-th odd number up to the n-th odd prime.
2
2, 4, 6, 9, 11, 14, 16, 19, 23, 25, 29, 32, 34, 37, 41, 45, 47, 51, 54, 56, 60, 63, 67, 72, 75, 77, 80, 82, 85, 93, 96, 100, 102, 108, 110, 114, 118, 121, 125, 129, 131, 137, 139, 142, 144, 151, 158, 161, 163, 166, 170, 172, 178, 182, 186, 190, 192, 196, 199, 201, 207, 215
OFFSET
1,1
COMMENTS
Define the alternating sum S(n) = -Sum_{j=0..n} (-1)^j*j = -A130472(n).
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.
LINKS
FORMULA
a(n) = -A130472(A065091(n)) + A130472(A005408(n-1) - 1).
a(n) = (1/2)*(-1 + 2n + A000040(n + 1)). - David Trimas, Jul 21 2024
EXAMPLE
a(1) = 1 - 2 + 3 = 2;
a(2) = 3 - 4 + 5 = 4;
a(3) = 5 - 6 + 7 = 6;
a(4) = 7 - 8 + 9 - 10 + 11 = 9;
a(5) = 9 - 10 + 11 - 12 + 13 = 11;
a(6) = 11 - 12 + 13 - 14 + 15 - 16 + 17 = 14.
MAPLE
A130472 := proc(n) (-1)^n*floor((n+1)/2) ; end:
A005408 :=proc(n) 2*n+1 ; end:
A065091 :=proc(n) ithprime(n+1) ; end:
A163057 := proc(n) -A130472(A065091(n)) + A130472(A005408(n-1) -1) ; end: seq(A163057(n), n=1..80) ; # R. J. Mathar, Jul 27 2009
MATHEMATICA
1/2 (-1 + 2 # + Prime[# + 1]) & /@ Range[100] (* David Trimas, Jul 21 2024 *)
PROG
(Python)
from sympy import sieve as A000040
def A163057(n): return n + A000040[n + 1] // 2 # Karl-Heinz Hofmann, Jul 23 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
Rephrased in terms of A130472 by R. J. Mathar, Jul 27 2009
STATUS
approved