求GCD(Greatest Common Divisor)

最常用的是欧几里得算法:

gcd(a,0) = a
gcd(a,b) = gcd(b, a%b)

算法复杂度在对数级(O(lg(max(a,b))).

你可能感兴趣的:(Algorithms)