What is the sum of $k^2(n - k)$ for $k = 1$ to $k = n$? What is the value of $\sum\limits_{k=1}^n k^2(n - k)$?
The problem I had was: 
for a square grid of size $n \times n$ how many squares have their corners on the intersecting points of the grid. (There are $n \times n$ points, the square's length is $n - 1$).
For every $k$-sized square there are $n - k$ possible squares with their corners laying on the edges of the bigger square. For every $k$-sized square there are $\frac{k(k + 1)(2k + 1)}{6}$ possible smaller squares.

\begin{align*}
\sum_{k=1}^n k^2(n-k)&=n\sum_{k=1}^n k^2-\sum_{k=1}^n k^3 \\[5pt]
&=n\left(\frac{n}{6}(n+1)(2n+1)\right)-\frac{n^2}{4}(n+1)^2\\[5pt]
&=  \frac{n^2}{12}(n^2-1),
\end{align*}
by linearity of summation and the formulae for $\sum k^2$ and $\sum k^3$.
