<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] Proof 1. (Exercise 2.5.1 in Dias Agudo, Cândido da Silva, Matemáticas Gerais III).  Let $S:=\sum_{k=1}^{n}k^{2}$. Consider $(1+a)^{3}=1+3a+3a^{2}+a^{3}$ and sum 
$(1+a)^{3}$ for $a=1,2,\ldots ,n$:
$$\begin{eqnarray*}
(1+1)^{3} &=&1+3\cdot 1+3\cdot 1^{2}+1^{3} \\
(1+2)^{3} &=&1+3\cdot 2+3\cdot 2^{2}+2^{3} \\
(1+3)^{3} &=&1+3\cdot 3+3\cdot 3^{2}+3^{3} \\
&&\cdots  \\
(1+n)^{3} &=&1+3\cdot n+3\cdot n^{2}+n^{3}
\end{eqnarray*}$$
The term $(1+1)^3$ on the LHs of the 1st sum cancels the term $2^3$ on the RHS of the 2nd,  $(1+2)^3$, the $3^3$, $(1+3)^4$, the $4^3$, ..., and $(1+n-1)^3$ cancels $n^3$. Hence
$$(1+n)^{3}=n+3\left( 1+2+\ldots +n\right) +3S+1$$
and 
$$S=\frac{n(n+1)(2n+1)}{6},$$
because $1+2+\ldots +n=\dfrac{n\left( n+1\right) }{2}$.
Proof 2. (Exercise 1.42 in Balakrishnan, Combinatorics, Schaum's Outline of Combinatorics). From
$$\binom{k}{1}+2\binom{k}{2}=k+2\frac{k\left( k-1\right) }{2}=k^{2},$$
we get
$$\begin{eqnarray*}
S &:&=\sum_{k=1}^{n}k^{2}=\sum_{k=1}^{n}\binom{k}{1}+2\binom{k}{2}
=\sum_{k=1}^{n}\binom{k}{1}+2\sum_{k=1}^{n}\binom{k}{2} \\
&=&\binom{n+1}{2}+2\binom{n+1}{3} \\
&=&\frac{n\left( n+1\right) \left( 2n+1\right) }{6}.
\end{eqnarray*}$$
</s>