counting the rectangles in nxn square

233 Views Asked by At

How many different rectangles can be seen in an $$ n \times n $$ grid like the one shown? Of course the rectangles must be at least one box wide and deep, and squares are allowed. https://i.stack.imgur.com/xHdVr.jpg

I'm ask for a help hand. greetings.

2

There are 2 best solutions below

0
On BEST ANSWER

$\binom {n+1}2^2$

Let the rectangle be defined by its top-left point ($x_1, y_1$) and bottom-right point ($x_2, y_2$) such that $0 \le x_1 < x_2 \le n$ and $0 \le y_1 < y_2 \le n$. The number of ways to pick such pairs of $x_1, x_2$ is $\binom {n+1}2$, and ditto for $y_1, y_2$.

0
On

Such a rectangle can be specified by choosing the $x$ coordinates of the vertical sides and the $y$ coordinates of the horizontal ones. In other words, choose integers $x_1,x_2,y_1,y_2$ such that $0\le x_1< x_2\le n$ and $0\le y_1< y_2\le n$. How many ways are there to do this?