I need to cluster some rectangles which have all the same size, for example $a = 10$ and $b = 20$.
My goal is to create a new rectangle $x$ where the side length $a'$ and $b'$ is minimal, so it should be more or less a cube.
My first approach simply this: $n$ is the number of rectangles.
$a' = \sqrt(n)$ $b' = \frac n {a'}$
Both values are rounded down to the next integer.
My problem is that is works great for the most values, for example $n = 24$, I get $a' = 4$ and $b' = 6$. Only when i use 10, i have a problem because $\sqrt(10) = 3$, so i have $b' = 3$ as well... but it should be $a'=2$ and $b'=5$...
is there a better way to calculate this?