leastCommonMultipleBig function

BigInt leastCommonMultipleBig (BigInt a, BigInt b)

Returns the least common multiple (lcm) of two BigInt using Euclid's algorithm.

Implementation

BigInt leastCommonMultipleBig(BigInt a, BigInt b) {
  if ((a == BigInt.zero) || (b == BigInt.zero)) {
    return BigInt.zero;
  }

  return ((a ~/ greatestCommonDivisorBig(a, b)) * b).abs();
}