# How can I determine the function for summing a series of integers? [duplicate]

I want to sum a series of integers, say from 1 to 5, but I want to generalise this function. I have seen that the function is:

$$\text{sum} = \frac{n(n+1)}{2}$$ where $n$ is the number to sum up to

So for $n=5$, i.e. $1 + 2 + 3 + 4 + 5$, the sum is $15$.

My question is, how could I (without knowing by heart) work out that function myself?

-

## marked as duplicate by Hakim, Daniel Fischer♦, Davide Giraudo, Brad, alexqwxJul 25 '14 at 21:38

arrange the numbers in a triangle: $${}$$o$${}$$o o$${}$$o o o$${}$$o o o o$${}$$o o o o o  ... How many dots are there in the whole triangle? – enthdegree Jul 25 '14 at 21:01

I'll show by building from a few concepts.

The following technique is called telescoping, $$\sum_{j=1}^{n}(a_j - a_{j-1}) = a_n - a_0$$ proof, $$a_1 + a_2 + \dots + a_n +$$ $$(-a_0) + (-a_1) + \dots +(-a_{n-1})$$

Adding them all up, we end up with $a_n - a_0$.

Next I will show you the sum of first $n$ odd numbers. Note the identity

$$k^2 - (k-1)^2 = 2k-1, k\in \mathbb{Z}$$

where $2k-1$ is the $k^{th}$ odd number. The sum of the first $n$ odd number is then $$\sum_{k=1}^{n}(2k-1)$$

Using the identity mentioned above,

$$\sum_{k=1}^{n}(2k-1)$$ $$=\sum_{k=1}^{n}(k^2 - (k-1)^2)$$

which by telescoping, is

$$1^2 + 2^2 + \dots + n^2 +\\ (-0^2) - 1^2 - 2^2 \dots -(n-1)^2\\ = n^2$$

The sum of the first $n$ odd numbers is then $n^2$. Finally we use all of these to prove the sum of first $n$ integers. Note that the $k^{th}$ odd number is,

$$2k-1$$

and the summation for first $n$ odd number is,

$$\sum_{k=1}^{n}(2k-1)$$

We want to get rid of $2k-1$ to just $k = (2k-1)-k+1$, thus the sum of first $n$ natural numbers is,

$$\sum_{k=1}^{n}k = \sum_{k=1}^{n}(2k-1 - k + 1)$$ $$\sum_{k=1}^{n}k = \sum_{k=1}^{n}(2k-1) - \sum_{k=1}^{n}k + \sum_{k=1}^{n}1$$ $$\sum_{k=1}^{n}k + \sum_{k=1}^{n}k = \sum_{k=1}^{n}(2k-1) + \sum_{k=1}^{n}1$$

We already know the sum of first $n$ odd and $\sum_{k=1}^{n}1 = n$, therefore $$2\sum_{k=1}^{n}k = n^2 + n$$ $$\sum_{k=1}^{n}k = \dfrac{n^2 + n}{2}$$ $$\sum_{k=1}^{n}k = \dfrac{n(n+1)}{2}$$

This is just one of them, there are lots more. But for me this is the simplest.

-

Let $$S = 1 + 2 + 3 + ... + n$$

Rearrange to the form $$S = (n + 1) + ((n-1) + 2) + ... + (n - (n - 1) + n) =(n+1)+(n+1)+...(n+1)$$

So there are $n/2$ terms (because we've paired them off), so $$S = \frac{n}{2}(n+1) = \frac{n(n+1)}{2}$$

-

Define $S(n)$ as:

$$S(n)=\sum_{k=1}^n k$$

Then it is easy to see that $S(n)$ is a second degree polynomial in $n$. Therefore

$$S(n)= \frac{1}{2}(n-2)(n-3)S(1) -(n-1)(n-3)S(2) + \frac{1}{2}(n-1)(n-2)S(3) = \frac{1}{2}n (n+1)$$

-

This formula is usually attributed to Gauss, who worked it out in a really simple way (the legend say, to finish earlier the boring homework of summing all naturals up to 100)

Think of numbers as sums of 1s. $$1$$ $$1+1$$ $$1+1+1$$ $$1+1+1+1$$ $$\cdots$$ If you try to calculate the area of this triangle (where area = number of ones) you get, simply, Gauss' formula $$A=sum=\frac{n(n+1)}{2}$$ Where the $n+1$ is justified by the fact that your upper vertex has not a lenght of $0$. You can imagine it as a trapeze with bases of length $1$ and $n$ and height of $n$.

-