Given the dimensions of two rectangles, find how many smaller rectangles fit the bigger one
<p>I have this web application in PHP where i get the dimensions of two rectangular objects. I need to know:</p>

<ol>
<li>Which is the bigger rectangle  </li>
<li>How many smaller rectangles can fit in the bigger rectangle.</li>
</ol>

<p>Okay, the first one is very easy. But the second one is pretty difficult. It should account for mixed orientations meaning that the smaller rectangle can both be landscape and portrait when fit inside the bigger rectangle.</p>

<p>Is there a math equation for this? I'd want to post an image but new users can't. I've uploaded the image here in this link <a href="http://flic.kr/p/bdFFAp" rel="nofollow">http://flic.kr/p/bdFFAp</a> so that you guys can get the picture (pun intended lol).</p>

<p>Thanks!</p>
