How many squares are there in a grid of size $m \times n$? Simplify the result for the case $n \times n$.
Assuming $m \leqslant n$ by symmetry, we proceed by counting the squares according to their size. The $1 \times 1$ squares are in number of $m n$ (we can identify them by their top-left corner, for example), the $2 \times 2$ squares are in number of $(m-1)(n-1), \ldots$, and so on, up to the squares of size $m \times m$. In total, we count: $\sum_{k=0}^{m-1}(m-k)(n-k)$ squares.