List of usage examples for org.apache.commons.math.util MathUtils lcm
public static long lcm(long a, long b)
Returns the least common multiple of the absolute value of two numbers, using the formula lcm(a,b) = (a / gcd(a,b)) * b
.
From source file:org.netxilia.functions.MathFunctions.java
/** * Returns the least common multiple of one or more integers. Integer_1, integer_2,... integer_30 are integers whose * lowest common multiple is to be calculated. * /*from w w w . ja v a2s . c om*/ * @param values * @return */ public long LCM(Iterator<Long> values) { if (!values.hasNext()) { return 1; } long result = values.next(); while (values.hasNext()) { result = MathUtils.lcm(result, values.next()); } return result; }