/**@author 欧阳子木
* Algorithm Gossip: 最大公因数、最小公倍数
* GCD * LCM = 两数乘积
* 设两个数为x和y,其最大公约数为a,则
最小公倍数为(x/a)*(y/a)*a=x *y/a,
最大公约数和最小公倍数的乘积为x *y/a*a=x *y
得证
* @param args
*/
public static int GCD(int number1 , int number2){
int temp = 0;//辗转相除法
while(number2!= 0){
temp = number1 % number2;
number1 = number2;
number2 = temp;
}
return number1;
}
// GCD * LCM = 两数乘积
public static int LCM(int number1 , int number2){
return (number1 * number2) / GCD(number1, number2);
}