Can you explain this please $T(n) = (n-1)+(n-2)+…1= \frac{(n-1)n}{2}$ 
Possible Duplicate:
Proof for formula for sum of sequence 1+2+3+…+n? 

Can you explain this please 
$$T(n) = (n-1)+(n-2)+…1= \frac{(n-1)n}{2}$$
I am really bad at maths but need to understand this for software engineering.

For example, if we wish to add the numbers
$$
1+2+3+4+5+6
$$
you can pair them as such
$$
(1+6)+(2+5)+(3+4)=7+7+7=21.
$$
But, here $n=7$ and there are $\frac{n-1}{2}=3$ pairs of $n=7$.  Thus we have that the sum is $\frac{n-1}{2}\cdot n=3\cdot 7=21$.  In general, you can pair the sum
$$
1+2+3+\cdots +(n-2)+(n-1)
$$
as pairs $(n-1+1), (n-2+2), (n-3+3), \ldots$ and so forth.  This will give you $\frac{n-1}{2}$ pairs of $n$ if $n-1$ is even.  If $n-1$ is odd, leave off $n-1$ and do it for $1+\cdots +(n-2)$ and add on $n-1$ to obtain the same formula.
