<s>[INST] Sum of First $n$ Squares Equals $\frac{n(n+1)(2n+1)}{6}$ I am just starting into calculus and I have a question about the following statement I encountered while learning about definite integrals:
$$\sum_{k=1}^n k^2 = \frac{n(n+1)(2n+1)}{6}$$
I really have no idea why this statement is true. Can someone please explain why this is true and if possible show how to arrive at one given the other?
 [/INST] A High School Proof: 
$$S_n = 1^2 + 2^2 + 3^2 +\dots+ n^2$$
We know,
$$r^3 - 3r^2 + 3r - 1 = (r-1)^3 $$
$$r^3 - (r-1)^3 = 3r^2 - 3r + 1$$
When $r=1, 2, 3,\dots, n$
$$1^3 - 0^3 = 3*1^2 - 3*1 + 1\qquad(1)$$
$$2^3 - 1^3 = 3*2^2 - 3*2 + 1\qquad(2)$$
$$3^3 - 2^3 = 3*3^2 - 3*3 + 1\qquad(3)$$
$$\dots\dots\dots\dots\dots\dots\dots\dots\dots$$
$$n^3 - (n-1)^3 = 3n^2 - 3n + 1\qquad(n)$$
By summing all the equations (from 1 to n) we get,
$$n^3 - 0^3 = 3(1^2 + 2^2 + 3^2 +\dots+ n^2) - 3(1+2+3+\dots+n) + (1+1+1+\dots)$$
$$n^3 = 3S_n - 3\frac{n(n+1)}{2} + n$$
\begin{align}
3S_n & = n^3 + \frac{3n(n+1)}{2} - n\\
& = \frac{2n^3 + 3n^2 + 3n - 2n}{2}\\
& = \frac{2n^3 + 3n^2 + n}{2}\\
& = \frac{n(2n^2 + 3n + 1)}{2}\\
& = \frac{n(2n^2 + 2n + n + 1)}{2}\\
& = \frac{n\{2n(n+1)+1(n+1)\}}{2}\\
& = \frac{n(n+1)(2n+1)}{2}\\
\end{align}
$$\therefore S_n = \frac{n(n+1)(2n+1)}{6}$$
</s>