The issue at hand, is I will have a rectangle of size x. This rectangle will contain n smaller rectangles. Each of these smaller rectangles is the same size though. I need to figure out how to calculate the SIZE that the smaller rectangles should be, based on 1) the size of the encompassing rectangle 2) the number of smaller rectangles that go inside it so that I can fill the maximum area inside the main rectangle, without altering the height/width ratio of the smaller rectangles (ie they can grow in size, but they can't be sized in a way that it distorts their height/width ratio, so some area in the encompassing rectangle will not be filled in, and this is ok) both these values are known when I need to do the calculation. Here are a few images to illustrate this (note sizes of red rectangles in each image are always the same). Is there any specific geometric formula to do this?