How abt dis :

The algorithm reduces the problem of finding the GCD by repeatedly applying
these identities:
1. gcd(0, v) = v, because everything divides zero, and v is the largest
number that divides v. Similarly, gcd(u, 0) = u. gcd(0, 0) is not typically
defined, but it is convenient to set gcd(0, 0) = 0.

2. If u and v are both even, then gcd(u, v) = 2·gcd(u/2, v/2), because 2 is
a common divisor.

3. If u is even and v is odd, then gcd(u, v) = gcd(u/2, v), because 2 is not
a common divisor. Similarly, if u is odd and v is even, then gcd(u, v) =
gcd(u, v/2).

4. If u and v are both odd, and u > v, then gcd(u, v) = gcd((u - v)/2, v).
If both are odd and u < v, then gcd(u, v) = gcd((v - u)/2, u).




Which is better ?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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