leastCommonMultipleBig function

BigInt leastCommonMultipleBig(
  1. BigInt a,
  2. 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();
}