最小公倍数(LCM)=两整数的乘积÷最大公约数(GCD)
1.辗转相除法

1 int gcd1(int x,int y) 2 { 3 int rr; 4 while(y) 5 { 6 rr=x%y; 7 x=y; 8 y=rr; 9 } 10 return x; 11 } 12 13 int gcd2(int a,int b) 14 { 15 return b==0 ? a:gcd2(b,a%b); 16 }
2.辗转相除法

1 int gcd3(int a,int b) 2 { 3 while(a!=b) 4 { 5 if(a>b) a=a-b; 6 else b=b-a; 7 } 8 return a; 9 }
3.确定一个范围,暴力枚举
4.分解质因数求