//最大公约数(greatest common divisor),运用递归
int gcd(int a,int b){//注意a要求大于b
return !b?a:gcd(b,a%b);
}
//最小公倍数(Lowest Common Multiple,LCM)的求值运用到最大公约数
int lcm(int a,int b){
int d=gcd(a,b);
return a/d*b;
}
转载于:https://www.cnblogs.com/hebust/p/9393939.html