标签:
Recursive:
int gcd(int a, int b) {
return b ? gcd(b, a%b) : a;
}
Iterative:
int gcd(int a, int b) {
while (b) {
int tmp = b;
b = a%b;
a = tmp;
}
return a;
}
就是喜欢简洁。
Reference:
[1] http://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html
标签:
原文地址:http://www.cnblogs.com/wubdut/p/5617386.html