2
$\begingroup$

Gauss formula to add numbers from $1-100$ is:

$$ \frac{n(n+1)}{2}$$

How can this be made applicable for arbitrary range, lets say $3-30$? Is there an easy way of doing that rather then linearly adding the numbers up?

$\endgroup$
  • 3
    $\begingroup$ Hint: add numbers 1-30, 1-2, subtract. $\endgroup$ – dxiv Sep 7 '16 at 4:56
1
$\begingroup$

The sum of the natural numbers from $a$ to $b$ inclusive is $$\frac{(a+b)(b-a+1)}{2}.$$

$\endgroup$
  • $\begingroup$ Thanks, i think it is (a+b)(b-a+1)/2 ? $\endgroup$ – user1767754 Sep 7 '16 at 5:03
  • $\begingroup$ Yes. Thank you. $\endgroup$ – Rafael Holanda Sep 7 '16 at 5:04
1
$\begingroup$

As a quick guideline and/or explanation of how to get the answer, consider adding the sequence to itself in reverse order:

$\begin{eqnarray} 2S_n & = & S_n + S_n \\ & = & a & + (a + d) & + \ldots & + (a + (n-1)d) & + (a + (n-1)d) & + \ldots & + (a + d) & + a \\ & = & a & + (a + d) & + \ldots & + (a + (n-1)d) \\ & + & (a + (n-1)d) & + (a + (n-2)d) & + \ldots & + a \\ & = & (2a + (n-1)d) & + (2a + (n-1)d) & + \ldots & + (2a + (n-1)d) \\ & = & n(2a + (n-1)d) \\ \therefore S_n & = & \frac{n}{2}(2a + (n-1)d)\end{eqnarray}$

which you can rearrange to give the alternative form.

$\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.