# Number of squares in $n\times n$ chessboard

Recently came a across a question about calculating the number of squares in 8x8 chessboard. Being not that good in maths my answer was 64 but to my surprise it was 204.So how is it?And how to go about calculating number of squares in $n\times n$ chessboard??

-
They are considering "squares" that are 1x1, 2x2, ..., up to 8x8. With this in mind, maybe you could come up with a way to calculate how many are in an n x n chessboard. – The Chaz 2.0 Mar 6 '12 at 5:51

The number of squares on an $n \times n$ chessboard is $$\dfrac{n(n+1)(2n + 1)}{6}$$
There are indeed exactly $n^2$ instances of $1\times1$ squares. However, there are also $m\times m$ squares for all $1\le m\le n\;$ on the chessboard! Now any $m\times m\;$ square's position on the board is determined by the location of its upper leftmost square. So, working locally (i.e. for a given number $m$), how many squares are on the board with at least $m-1$ squares both to the right of it and below it?