<s>[INST] 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.
 [/INST] Let's start by splitting the sum into two different sums:
$$
\sum_{k=1}^n k^2(n-k)=\sum_{k=1}^n k^2n-\sum_{k=1}^n k^3=n\sum_{k=1}^n k^2-\sum_{k=1}^n k^3
$$
Now we have $\sum_{k=1}^nk^2=\frac{n(n+1)(2n+1)}{6}$ and $\sum_{k=1}^n k^3=\left( \frac{n(n+1)}{2}\right) ^2=\frac{n^2(n+1)^2}{4}$ and together
$$
n\frac{n(n+1)(2n+1)}{6}-\frac{n^2(n+1)^2}{4}=\frac{2n^2(n+1)(2n+1)-3n^2(n+1)^2}{12}=n^2(n+1) \frac{2(2n+1)-3(n+1)}{12}=n^2(n+1)\frac{4n+2-3n-3}{12}=\frac{n^2(n+1)(n-1)}{12}
$$
</s>