leastCommonMultiple function

int leastCommonMultiple (int a, int b)

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

Implementation

int leastCommonMultiple(int a, int b) {
  if ((a == 0) || (b == 0)) {
    return 0;
  }

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