2
$\begingroup$

Is there a generalized formula for finding a sum such as this one? I'm going over an old quiz for a programming class but I'm not able to solve it:

$$ \sum_{n=5}^{204} (n - 2) $$

I know this is probably dead simple, but I'm seriously lacking on the math side of computer science.

$\endgroup$
4
$\begingroup$

$$\sum_{n=5-4}^{204-4}((n+4)-2)=\sum_{n=1}^{200}(n+2)=\frac{200.(200+1)}{2}+2.200=20500$$

$\endgroup$
7
$\begingroup$

Hint:

$$ \sum_{i=1}^{n}i = \frac{n(n+1)}{2}, \quad \sum_{i=1}^{n}1 = n.$$

$\endgroup$
3
$\begingroup$

The other answers mention that you require the sum $\sum_{1}^{k} n=\frac{k(k+1)}{2}$. It is also useful to note that $$\sum_{n=5}^{204}(n-2)=\sum_{n=3}^{202}n$$ This is called shifting the index, and to convince yourself it works you can just write out the first few terms of each side.

$\endgroup$
2
$\begingroup$

the only thing that you have to kcon is that : $$ \sum_{k=0}^{n} k = \frac{n(n+1)}{2} $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.