Recursive:html
int gcd(int a, int b) {
return b ? gcd(b, a%b) : a;htm
}blog
Iterative:gc
int gcd(int a, int b) {while
while (b) {co
int tmp = b;return
b = a%b;gcd
a = tmp;arc
}
return a;
}
就是喜歡簡潔。
Reference:
[1] http://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html