I have a rectangle width x height, and N squares of same unknown size. I must determine the maximum size of these squares and number of rows and columns to fit perfectly (UP
Your question is not consistent. First, you state the problem as "determine the maximum size of these squares and number of rows and columns to fit perfectly into the rectangle." (emphasis added).
But then you give a sample final result that allows empty space.
So which is it?
If you need the squares to fit perfectly in the rectangle with no empty space and no squares extending beyond the bounds of the rectangle, then the size of the maximal square would equal the greatest common divisor of the length and width of the rectangle.
See http://en.wikipedia.org/wiki/Greatest_common_divisor#A_geometric_view