leastCommonMultipleOfManyBig function

BigInt leastCommonMultipleOfManyBig (List<BigInt> integers)

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

Implementation

BigInt leastCommonMultipleOfManyBig(List<BigInt> integers) {
  if (null == integers) {
    throw ArgumentError.notNull('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;
}