How many rectangles can be found in a 5 x 5 square? Diagonal rectangles are allowed.

185 Views Asked by At

In a 5 x 5 square, there are 225 rectangles, but what if I allow for rectangles that are diagonal? How many more rectangles would I have? Here is an example of a diagonal rectangle: enter image description here

1

There are 1 best solutions below

2
On BEST ANSWER

This can be found at OEIS A085582 and for $n=5$ the answer is $130$.

Or, as I see, you're allowing rectangles where the "side length is $0$" i.e. the corners reside at same point. Would then a non-axis-aligned rectangle also be allowed to be "just a line"? If not, add the number of non-axis-aligned, from A113751 (for $n=5$ it's $30$) to the axis-aligned number to get

$$225 + 30 = 255.$$

If you also allow degenerate diagonal rectangles, read on.

EDIT: As suggested in the comments, the degenerated rectangles are simply counted by choosing two points from the square (we can even choose the same point to just get a point as the rectangle). So it is

$${n^2\choose 2} + n^2 = \frac{n^2(n^2+1)}{2}.$$

Add this to the number of non-degenerate rectangles given by OEIS A085582. For $n=5$ we get

$$130 + 325 = 455.$$

(That's what I get with my brute force program too.)