Finding minimum number of squares inside a rectangle

3.2k Views Asked by At

I have this question where I have to find the minimum number of squares (of the same dimensions) inside of a rectangle. I found that this problem has a solution where I can calculate the LCM and the HCF of the given sides of the rectangle and by finally dividing the LCM by the HCF... I get the correct answer! I want to know why this logic works? Can someone explain it?

1

There are 1 best solutions below

1
On BEST ANSWER

The biggest square that can tile a rectangle with sides $a,b$ has side $\gcd(a,b)$. The number of squares you will then use is

$$\frac{a}{\gcd(a,b)}\cdot\frac{b}{\gcd(a,b)} = \frac{ab}{\gcd(a,b)^2} = \frac{\mathrm{lcm}(a,b)}{\gcd(a,b)}$$

because $ab=\mathrm{lcm}(a,b)\cdot\gcd(a,b)$.