最小公倍数(Least Common Multiple)

最小公倍数=两个数的乘积/两个数的最大公约数。

接上篇求最大公约数方法,最小公倍数的代码例如以下:

public class LCM {
	//最小公倍数=两数乘积/最大公约数
	public static int lcm(int m, int n){
		return m*n/GCD.gcd(m,n);
	}
	public static void main(String[] args){
		System.out.println(lcm(0,9));
	}
}

结果:

0

原文地址:https://www.cnblogs.com/gcczhongduan/p/5258703.html