# Algorithm to find the largest number of identical squares that fit into a square with a specified area (ex: 972) [closed]

I have a question on my homework that I cannot figure out. The question is: What is the largest number of identical squares whose areas are whole numbers that would fit in a square whose area is 972cm^2

• So it seems clear that $1x1$ squares will get you the maximum, so now the question is how many $1x1$ squares fit into a square of side length $\sqrt{972}$. – Cheerful Parsnip Dec 3 '19 at 2:06

You will always maximize the number of squares you can fit by using those with side length $$1$$.
If the big square has area $$n$$, then the side length is $$\sqrt{n}$$. Then, you can fit $$\lfloor \sqrt{n} \rfloor^2$$ squares into it.
For example.. if the area is $$972$$, the side length is $$31.17$$ approx, which means you can fit a $$31\times 31$$ grid of squares inside it.
• Does anything guarantee you can’t place them in such a way that more than $961$ fit? That would be incredibly sneaky, but you never know. – URL Dec 3 '19 at 4:14
• @URL Clearly not. Considering the projections of the filling on each side, it's possible to improve any solution which isn't simply filling in $31\times 31$ squares greedily. – Don Thousand Dec 3 '19 at 4:34