The sum of the first *n* squares is

The numbers are called the square pyramidal numbers.

Many different proofs exist. Seven different proofs can be found in Concrete Mathematics and even a visual proof has been published (via @MathUpdate).

One of the simplest proofs uses induction on *n*. This approach assumes that you know (or guess) the correct formula beforehand, though.

This post will show a derivation which is a formalization of the derivation shown on wikipedia. It revolves around manipulating sums and the fact that

since .

We will now write in three different ways. The first simply inserts the above expression for :

The second reverses the order of summation for the inner sum:

The third starts as the first and does a series of manipulations:

(the manipulations being: Switching the order of summation, change of variable , change of variable , renaming , ).

We now add together these three expressions for and get

which, after dividing each side by 3, produces the wanted formula.