I am a mobile developer and I have a problem and need to find a formula to get the dimensions of squares to fit inside a space. My problem is that I have a rectangle of dimensions lxw and need to fit n number of squares into it. Where n can change to any number from 2 up to 30 or more. While l and w can be any dimension but will mainly be in the range upward of 600x400. What I need is to fit exactly n number of squares into this space, the dimensions of the squares can go as small or as large as required.
Also I require the the number of rows and columns that will fit these squares in them. The squares will be displayed as evenly as possible across these rows and columns.
I have found a similar solution but I simply don't have the mathematics undestanding to get my head around the explanation. Also the explanation mentions that the grid is 'w squares wide, h squares high' however I don't know how many squares high and wide my screen will be, maybe I'm misunderstanding something? If someone could dumb this formula down for me it would be appreciated.