The sum of the first n squares is
sn=k=1∑nk2=61n(n+1)(2n+1).
The numbers s0,s1,s2,… 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
k2=j=1∑k(2j−1)
since k2−(k−1)2=2k−1.
We will now write sn in three different ways. The first simply inserts the above expression for k2:
sn=k=1∑nj=1∑k(2j−1).
The second reverses the order of summation for the inner sum:
sn=k=1∑nj=1∑k(2(k−j)+1).
The third starts as the first and does a series of manipulations:
sn=k=1∑nj=1∑k(2j−1)=j=1∑nk=j∑n(2j−1)=j′=1∑nk=n+1−j′∑n(2(n+1−j′)−1)=j′=1∑nk′=1∑j′(2(n−j′)+1)=k=1∑nj=1∑k(2(n−k)+1)
(the manipulations being: Switching the order of summation, change of variable j′=n+1−j, change of variable k′=k+j′−n, renaming j′→k, k′→j).
We now add together these three expressions for sn and get
3sn=k=1∑nj=1∑k(2n+1)=(2n+1)k=1∑nk=(2n+1)2n(n+1)
which, after dividing each side by 3, produces the wanted formula.