求最大公倍数
1 int GCD(int a,int b) 2 { 3 if(a % b == 0) return b; 4 else 5 return GCD(b,a%b); 6 }
求最小公倍数
1 int LCM(int a,int b) 2 { 3 return a*b/GCD(a,b); //最小公倍数等于两数乘积除以最大公约数 4 }