The sum of the first n terms of an arithmetic sequence is given by:

\[S_n=\frac{n}{2} (2a+(n-1)d)\]

where the first term is a and the common difference is d. Alternatively, we can write this as:

\[S_n=\frac{n}{2} (a+L)\]

where L is the last term.

## Proof

Suppose we have a general arithmetic sequence with first term a and common difference d. Then the sum of the first n terms, \(S_n\), is given by:

\[S_n=a+(a+d)+(a+2d)+ \cdots + (a+(n-3)d) + (a+(n-2)d) + (a+(n-1)d)\]

We can write \(2S_n\) as:

`2S_n=(( a,+(a+d),+(a+2d),+, \cdots, + (a+(n-3)d), + (a+(n-2)d), + (a+(n-1)d) ),(+ a,+(a+d),+(a+2d),+, \cdots, + (a+(n-3)d), + (a+(n-2)d) ,+ (a+(n-1)d) ))`

We can write the terms in reverse order the second time we sum them, giving:

`2S_n=(( a,+(a+d),+(a+2d),+ ,\cdots, + (a+(n-3)d), + (a+(n-2)d), + (a+(n-1)d) ),(+ (a+(n-1)d),+ (a+(n-2)d),+ (a+(n-3)d),+ ,\cdots, +(a+2d), +(a+d), +a ))`

Now we can group the term in the top row of the sum with the term below it, giving:

\[2S_n=[a+ (a+(n-1)d)]+[(a+d)+ (a+(n-2)d)]+[(a+2d)+ (a+(n-3)d)]+ \cdots + [(a+(n-3)d)+(a+2d)] + [(a+(n-2)d)+(a+d)] + [(a+(n-1)d)+a]\]

\[2S_n=[2a+(n-1)d)]+[2a+(n-1)d)]+[2a+(n-1)d)]+ \cdots + [2a+(n-1)d)] + [2a+(n-1)d)] + [2a+(n-1)d)]\]

\[2S_n=n[2a+(n-1)d)]\]

\[\therefore S_n=\frac{n}{2}[2a+(n-1)d)]\]

\[Q.E.D.\]

This trick of summing the r^{th} and (n-r+1)^{th} term to get n was famously said to be used by Gauss at the age of 8, when his teacher asked the class to add the numbers from 1 to 100 in the hope that this would take up the whole lesson and he wouldn't have to teach the class. However, Gauss quickly noticed that 1+100=101, 2+99=101 and so on for 50 pairs of numbers, so the sum is equal to 5050.