Find the sum of the areas of all odd-sided squares in a $9*8$ Grid.
What I Tried: As a general formula, I know that the number of squares in a $9*8$ Grid would be :- $$\rightarrow \frac{M(M + 1)(3N - M + 1)}{6}$$ Where $N \geq M$. So putting $N = 9$ and $M = 8$ gives :- $$\rightarrow \frac{8(9)(20)}{6}$$ Which is a total of $240$ squares.
Now, I am wondering whether there is a formula for finding the number of odd-sided squares, or even-sided squares, or both. For example in a $2*2$ grid you will have $4$ odd-sided and $1$ even sided square, assuming each small square's length to be $1$ unit.
I also have no idea on finding the area, because in that case I have no choice but to count the different odd-sided and sized squares independently, and then find out their area and add then up. The answer is given to be :- $$\rightarrow \sum\limits_{r=1}^4 (11-2r)(10-2r)(2r-1)^2 $$
How do we do this? How are we even getting the answer?
Can anyone help me? Thank You.
Hint: Take cases: I.e. when the side of square is $1,3,5,7$ units
More Bigger Hint:-