//最大公约数(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;
}
2024-03-17 20:34:22
//最大公约数(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;
}