Given an integer area A, how can one find integer sides w and h of a rectangle such that w*h = A and w+h is as small as possible? I’d rather the algorithm be simple than efficient (although within reasonable efficiency).
What would be the best way to accomplish this?
Finding out the prime factors of A, then combining them in some way that tries to balance w and h? Finding the two squares with integer sides with areas closest to A and then somehow interpolating between them? Any other method i’m not thinking of?
You just need to find:
The product of the two is always A, so these factors are your
wandhAnd of course you only need to search for one of them, because once you have
wyou just seth = A / w