What is an efficient equation to calculate the nth sum of the series -1 + 2 - 3 + .. + ( - 1)^n n?

120 Views Asked by At

Please tell me an efficient equation to calculate the nth sum of the series $$(-1) + 2 + (-3) + ... + (-1)^{n}\cdot n$$

2

There are 2 best solutions below

0
On BEST ANSWER

Hint: note that sum of two consecutive elements is const (exactly $1$).


Sum of all first elements except at most once (if $n$ is odd) is obvious ($1 \cdot \lfloor\frac{n}{2}\rfloor$), you have to add at most last number. It is not hard to come that

$$ S_n = \frac{n}{2} \cdot (-1)^n + \frac{(-1)^n-1}{4} = \frac{(-1)^n (1+2n) - 1}{4}$$

1
On

Guess by looking at the first few terms and then use induction to verify your guess.

$S_1=-1$, $S_2=1$, $S_3=-2$,... $S_n=?$.