GCD最大公约数算法
程序员文章站
2024-03-20 12:13:04
...
int gcd(int a, int b) {
int s = a < b ? a : b;
int l = a > b ? a : b;
int tmp = -1;
while (s) {
tmp = s;
s = l%s;
l = tmp;
}
return l;
}