leastCommonMultipleOfManyBig function

BigInt leastCommonMultipleOfManyBig(
  1. List<BigInt> integers
)

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

Implementation

BigInt leastCommonMultipleOfManyBig(List<BigInt> integers) {
  if (integers.length == 0) {
    return BigInt.one;
  }

  var lcm = integers[0].abs();

  for (var i = 1; i < integers.length; i++) {
    lcm = leastCommonMultipleBig(lcm, integers[i]);
  }

  return lcm;
}