[algogeeks] Re: Counting number of rectangles

2010-08-28 Thread Adam
Observation is very important here. Examples can make us more clear about the issue. For a given RN, we do count in two situations refered before separately. 1. In the first situation the qualifying rectangles will have their width w and height h being coprime. Thus the equation RN = h + w - 1 wi

[algogeeks] Re: Counting number of rectangles

2010-08-24 Thread Saikat Debnath
Thank you Adam, but the thing is I don't only want the solution but also, how to go about such questions? How do you came to a solution to this question? On Aug 24, 8:43 am, Adam wrote: > Write here again: > I find an easier non-recursive solution to compute the rectangle > number (represented as

[algogeeks] Re: Counting number of rectangles

2010-08-23 Thread Adam
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 a

[algogeeks] Re: Counting number of rectangles

2010-08-23 Thread Adam
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 a

[algogeeks] Re: Counting number of rectangles

2010-08-23 Thread Adam
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 pri