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?
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?
On
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.
The sum of the natural numbers from $a$ to $b$ inclusive is $$\frac{(a+b)(b-a+1)}{2}.$$