leastCommonMultipleOfMany function

int leastCommonMultipleOfMany (List<int> integers)

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

Implementation

int leastCommonMultipleOfMany(List<int> integers) {
  if (null == integers) {
    throw ArgumentError.notNull('integers');
  }

  if (integers.length == 0) {
    return 1;
  }

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

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

  return lcm;
}