Going up further in size, 3-by-3 grid square contains 36 rectangles, and a 4-by-4 grid square contains 100 rectangles. How many rectangles are contained in a 5-by-5 grid square? Can you discover the formula, in terms of n, for the number of rectangles in an n-by-n grid square?

*sort by* **best** latest

225

Tricky when trying to describe how you come up with the formula in a short description.

In it's simplest form:

n^3 (n cubed) plus the number of rectangles in the previous grid square (n-1)

But when making a formula you have to consider that the previous grid square also added the number of rectangles from the grid before it and so on and so on.

So in the 5x5 grid square n=5 and would work out like this:

n^3 + (n-1)^3 + (n-2)^3 + (n-3)^3 + (n-4)^3 =

(5^3) + (4^3) + (3^3) + (2^3) + (1^3) =

(5x5x5)+(4x4x4)+(3x3x3)+(2x2x2)+(1x1x1) =

(125) + (64) + (27) + (8) + (1) = 225

Reminds me of binary but with 3's and with deeper thought these 2 dimensional squares take on 3 dimensional properties, interesting.

If I was writing a computer program I would use this formula..

(n*(n+1)/2)^2

You can help the HubPages community highlight top quality content by ranking this answer up or down.

You got it first and with a great explanation. I'm glad no one attempted to count all 225 of them!

- See all 2 comments

Quiz Master beat me to it. The formula for the number of rectangles in an n-by-n square is equal to the square of the nth triangular number. The 5th triangular number is 15, and 15*15 = 225. So there are 225 rectangles in a 5-by-5 grid. The general formula is (n^4 + 2n^3 + n^2)/4.

The square of the nth triangular number is also equivalent to the sum of the first n cubes. So an alternative way to get the answer is adding 1+8+27+64+125 = 225.

Here is a sketch of a proof:

The number of different sizes of rectangles in an n-by-n grid is equal to the nth triangular number. This is because there are "n+1 Choose 2" ways to choose the dimensions of the rectangle. If a rectangle has dimensions A-by-B, then there are

2*(n+1-A)*(n+1-B)

of them if A and B are unequal. If A = B, then are are (n+1-A)*(n+1-B) of them. If you compute the sum over all A and B where both A and B are bounded between 1 and n, then you get a summation expression that is equivalent to the expanded product

(1+2+3+...+n)*(1+2+3+...+n)

which is the square of the nth triangular number.

You can help the HubPages community highlight top quality content by ranking this answer up or down.

Very nice proof outline. You're right, the sum of the first n cube numbers is equivalent to the square of the nth triangular number, so that's another way to count the squares.

- See all 2 comments

I am very surprised to not see a simple combination formula for this question. It boils down to this. For every rectangle you must have 2 vertical sides and 2 horizontal sides. Because there are X + 1 horizontal lines and Y + 1 vertical lines in a X by Y grid we can derive the total rectangles to equal the following formula

((x+1) choose 2) * ((y+1) choose 2) = # of Rects

Choose (a combinatorial formula):

n choose r

n!/(n-r)!(r!)

You can help the HubPages community highlight top quality content by ranking this answer up or down.

see pasxwill's answer, it is the same combinatorial argument you mention.