Greated Common Divisor
int GCD(int a, int b){ int temp; if(a < b) { temp = a; a = b; b = temp; } if(a % b == 0) return b; return GCD(b, a % b);}
Least Common Multiple
//最小公倍数等于两数之积除以最大公约数 int LCM(int a,int b){ return (a * b) / GCD(a, b); }
本文共 344 字,大约阅读时间需要 1 分钟。
Greated Common Divisor
int GCD(int a, int b){ int temp; if(a < b) { temp = a; a = b; b = temp; } if(a % b == 0) return b; return GCD(b, a % b);}
Least Common Multiple
//最小公倍数等于两数之积除以最大公约数 int LCM(int a,int b){ return (a * b) / GCD(a, b); }
转载于:https://www.cnblogs.com/alexeyqian/p/3406696.html