document.write( "Question 297613: How do I calculate all the possible rectangles that can fit into a 2D rectangle?
\n" ); document.write( "For instance if the large rectangle has height H = 2 and width W = 5 the total number of rectangles that can fit into it are 31. \r
\n" ); document.write( "\n" ); document.write( "what formula do I use to find all rectangles (including the large rectangle)that can fit into H x W? I tried dividing the rectangle by smaller values of H and W increasing, but still didn't get the right answer. Please help
\n" ); document.write( "
\n" ); document.write( "

Algebra.Com's Answer #214319 by Fombitz(32388)\"\" \"About 
You can put this solution on YOUR website!
For a \"H=2\" and \"W=5\" rectangle, you get
\n" ); document.write( "10 \"H=1\",\"W=1\" rectangles
\n" ); document.write( "8 \"H=1\", \"W=2\" rectangles
\n" ); document.write( "6 \"H=1\", \"W=3\" rectangles
\n" ); document.write( "4 \"H=1\", \"W=4\" rectangles
\n" ); document.write( "2 \"H=1\", \"W=5\" rectangles
\n" ); document.write( "5 \"H=2\", \"W=1\" rectangles
\n" ); document.write( "4 \"H=2\", \"W=2\" rectangles
\n" ); document.write( "3 \"H=2\", \"W=3\" rectangles
\n" ); document.write( "2 \"H=2\", \"W=4\" rectangles
\n" ); document.write( "1 \"H=2\", \"W=5\" rectangles
\n" ); document.write( "That's a total of \"45\" rectangles.
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( "Now for a formula.
\n" ); document.write( "Start simple and work up to see a pattern.
\n" ); document.write( "\"H=2\" , \"W=1\"
\n" ); document.write( "\"1x1=2\"
\n" ); document.write( "\"2x1=1\"
\n" ); document.write( "\"3\" total rectangles
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( "\"+H=2\", \"+W=2\"
\n" ); document.write( "\"+1x1=+4\"
\n" ); document.write( "\"+1x2=+2\"
\n" ); document.write( "\"+2x1=+2\"
\n" ); document.write( "\"+2x2=+1\"
\n" ); document.write( "\"+9+\"total rectangles.
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( "\"+H=2\", \"+W=3\"
\n" ); document.write( "\"+1x1=6\"
\n" ); document.write( "\"+1x2=4\"
\n" ); document.write( "\"+1x3=2\"
\n" ); document.write( "\"+2x1=3\"
\n" ); document.write( "\"+2x2=2\"
\n" ); document.write( "\"+2x3=1\"
\n" ); document.write( "\"+18+\"total
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( "\"+H=2\", \"+W=4\"
\n" ); document.write( "\"+1x1=8\"
\n" ); document.write( "\"+1x2=6\"
\n" ); document.write( "\"+1x3=4\"
\n" ); document.write( "\"+1x4=2\"
\n" ); document.write( "\"+2x1=4\"
\n" ); document.write( "\"+2x2=3\"
\n" ); document.write( "\"+2x3=2\"
\n" ); document.write( "\"+2x4=1\"
\n" ); document.write( "\"+30\" total rectangles.
\n" ); document.write( ".
\n" ); document.write( ".
\n" ); document.write( "You're starting to get a pattern.
\n" ); document.write( "The \"2xn\" rectangles sum from \"1\" to \"n\" in steps of \"1\" for a total of \"n%28n%2B1%29%2F2\".
\n" ); document.write( "The \"1xn\" rectangles sum for \"2\" to \"2n\" in steps of \"2\" or \"n%28n%2B1%29\".
\n" ); document.write( "So the grand total of rectangles in a \"2xn\" rectangle would be
\n" ); document.write( "\"S%28n%29=n%28n%2B1%29%2F2%2Bn%28n%2B1%29\"
\n" ); document.write( "\"S%28n%29=%283n%2F2%29%28n%2B1%29\"
\n" ); document.write( "
\n" );