Problem #026 - counting squares

607

I bet you have seen one of those Facebook publications where you have a grid and you have to count the number of squares the grid contains, and then you jump to the comment section and virtually no one agrees on what the correct answer should be... Let's settle this once and for all!

Problem statement

The image above is a colourful grid that has $$7$$ rows and $$10$$ columns. How many squares are hiding in that grid?

The problem in this post is not about complicated theorems or weird proofs, it is just about finding a way to systematically count all the squares in a figure like this... Other than tracing the squares with one's finger and whispering the count as you go, of course.

You can start with something simpler to warm up. How many squares are there in this smaller $$3 \times 3$$ grid?

If you need any clarification whatsoever, feel free to ask in the comment section below.