Write here again:
I find an easier non-recursive solution to compute the rectangle
number (represented as RN) of an h x w rectangle (which has a height
of h units and a width of w units):

Situation 1:

If (h and w are coprime) or (h = 1) or (w = 1)

then RN = h + w - 1.

Situation 2:

if h and w are not relatively prime, we can find the greatest common
divisor (represented as gcd) that makes
(1) h = h' x gcd, w = w' x gcd
and
(2) (h' and w' are coprime) or (h' = 1) or (w' = 1),

then we finally get the result RN = (h' + w' - 1) x gcd.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to