leastCommonMultiple function

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