Hello NOX AndrewFirst: does the pertain to any branch of mathematics? The closest is probably combinatorics, sequences and series, but a lot of it amounts to problem solving and application of logical analysis. You could say: using your common-sense - but in my experience, it's not that common!

Second, can I solve the problem? Yes.

The first thing to note is that in the examples you quote, the number of rectangles you can find includes the number of squares. So by 'rectangle' you're not excluding those rectangles that are also squares. I'll show you how to solve this one, and leave you to try the number of shapes that are specifically squares in a similar way.

First, let's agree that in an grid, there are rows and columns. Next, when I talk about a rectangle, I mean a rectangle that is made up of unit squares arranged in rows and columns.

OK. Let's start counting, beginning with the smallest rectangle, and working our way up to the largest, using an grid.

rectangle. (Which is, of course, a square.)Obviously we can have of these along the bottom row (since there are columns in our grid), and there are such rows. So the total number of rectangles is:rectangle. (That's a rectangle with rows and column.)

We can still fit of these along the bottom row, since these rectangles are just column wide. But we can now only make rows like this before we hit the top of the grid. So the total number of rectangles is:rectangle.

In a similar way, the number of these rectangles we can find is:... and so on, all the way up to:

rectangle.You should easily see that number of these is:Now we pause, and add up the number of rectangles we've found so far. It is:

You may recognise the series in the brackets as a simple AP (the sum of the first whole numbers), whose sum is:

So the number of rectangles we've found so far is:Now let's look at rectangles that are columns wide.

rectangle (That's row, columns)We can't fit so many along the bottom row now. In fact, only of them. But we can get rows. So the number is:rectangle (Another square, of course.)We can still fit of them along the bottom row. But we can now only get rows. So the number is:... and so on, up to:

rectangle.And the number of these is:Adding up in the same way as before, we now get the total:

Can you see that we can continue in the same way? The total number of rectangles 3 columns wide will be:

... and so on.

Finally, we get the total number of rectangles columns wide as:All that remains is to add up these totals, noticing that in each one, we have a common factor of . So the overall total is:

using the same AP formula as before, but with the 's this time. So the formula for the number of rectangles in an grid is:

Now you see if you can derive a formula for simply squares. (You may find it easier to assume that, for the sake of argument, .)

Grandad