How many squares fit in a rectangle

geometry

I have a rectangle R with a given width W and a given height H. I need to put n equally-sized squares in that rectangle in an orderly way (not diagonally) so that the squares fit optimally in the rectangle filling out all the available space (of course, in most cases a small space will remain empty). What is the square edge-length E for any given number n of squares? ($E$ must be an integer number).

If $n=1$ then $E$ is the rectangle's shorter edge-length

But what about any other values of $n$?

I am sorry if this is a naive question for math experts, but it has been a long time since I took math classes at school.

Illustrative example: I have a table $2$ meter $\times$ $1$ meter. I need to cut out $12$ pieces of square-sized paper to cover most of the surface of the table. What must be the edge length of each paper sheet to achieve this task?

Best Answer

You want to factor $n$ into two factors that are close to the ratio of W to H. This tells you how many squares are in each direction. Then divide W by the number of squares in its dimension and H by the number in its dimension and take the smaller.

As an example, suppose $W=50, H=30$. This gives $\frac WH = \frac 53$. If there are $a$ squares in the W direction and $b$ squares in the H direction we have $ab=n$ and want $a \approx \frac 53b$, so we can look for $\frac 53b^2 \approx n, b \approx \sqrt {\frac 35n}$. If $n=60$ we get $\sqrt {\frac35n}=\sqrt {36}=6$ and we can have $10 \times 6$. The square size will be $\frac {50}{10}=5$. This came out perfectly. If we had $n=35$ we would have to take $a=7,b=5$ and the sizes would be $\frac {50}7=7\frac 17, \frac {30}5=6$. As $6$ is smaller we use that and have $8$ units left in the W direction.

For your example, you can either lay out the squares $4 \times 3$ or $6 \times 2$. For the first the $1$ m dimension is limiting and you get $\frac 13$ meter squares. For the second the $2$ m dimension is limiting and you again get $\frac 26=\frac 13$ meter squares. It is a coincidence of the numbers chosen that these match.