List of utility methods to do BigInteger LCM
BigInteger | lcm(BigInteger a, BigInteger b) Least common multiple. http://en.wikipedia.org/wiki/Least_common_multiple lcm( 6, 9 ) = 18 lcm( 4, 9 ) = 36 lcm( 0, 9 ) = 0 lcm( 0, 0 ) = 0 if (a.signum() == 0 || b.signum() == 0) return BigInteger.ZERO; return a.divide(a.gcd(b)).multiply(b).abs(); |
BigInteger | lcm(BigInteger a, BigInteger b) lcm return a.multiply(b).divide(gcd(a, b));
|
BigInteger | lcm(BigInteger... nums) lcm return lcm(Arrays.asList(nums));
|
BigInteger | lcm(BigInteger... values) Calculates the least common multiple of the specified BigInteger big integer numbers. if (values.length == 0) return BigInteger.ONE; BigInteger lcm = values[0]; for (int i = 1; i < values.length; i++) { if (values[i].signum() != 0) { final BigInteger gcd = lcm.gcd(values[i]); if (gcd.equals(BigInteger.ONE)) { lcm = lcm.multiply(values[i]); ... |