We can prove this by induction.

For n = 1, n (n+1) (2n+1)/6 = 1*2*3/6 = 1. Therefore the relation is true.

Now, if we assume 1^2 + 2^2 + 3^2 …n^2 = n (n+1) (2n+1)/6

1^2 + 2^2 + 3^2 …n^2 + (n +1) ^2 = n (n+1) (2n+1)/6 + (n+1) ^2

= (n+1) [n (2n+1)/6 + n+1]

= (n +1) (2n^2 + n + 6n + 6)/6

= (n +1) (2n^2 + 7n + 6)/6

= (n +1) (2n^2 + 3n + 4n + 6)/6

= (n +1) (n (2n + 3) + 2(n + 3)/6

= (n +1) (n+2) (2n + 3)/6

= (n +1) (n+1+ 1) (2(n +1) +1)/6

Which is the expression n (n+1) (2n+1)/6, with n replaced by n+1.

So as the relation is true for n = 1, and if it is assumed true for any n, we can show that it is also true for n+1; the relation is true for all values of n.

We know that r^2 = r(r+1)-r.

Therefore,

Sum 1^2+2^2+3^2+4^2+...+n^2 = (1*2-1)+(2*3-2)+(3*4-3)+(4*5-4)+....{n*(n+1)-n].

= {1*2+2*3+3*4+4*5+...n(n+1)}- (1+2+3+...n).

= {{n+2)(n+1)n}/3 - n(n+1)/2.

= (n(n+1){2(n+2)-3}/6.

= n(n+1)(2n+1)/6.

Therefore 1^2+2^2+3^2+4^2+...+n^2 = n(n+1)(2n+1)/6.