Android Utililty Methods Long LCM

List of utility methods to do Long LCM

Description

The list of methods to do Long LCM are organized into topic(s).

Method

longlcm(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 .

if (a == 0 || b == 0) {
    return 0;
long lcm = FastMath.abs(ArithmeticUtils.mulAndCheck(a / gcd(a, b),
        b));
if (lcm == Long.MIN_VALUE) {
    throw new MathArithmeticException(
            LocalizedFormats.LCM_OVERFLOW_64_BITS, a, b);
...