lcm function

int lcm(
  1. int x,
  2. int y
)

Returns the least common multiple of two integers.

The result is always non-negative.

Implementation

int lcm(int x, int y) {
  if (x == 0 || y == 0) {
    return 0;
  }

  return ((x ~/ x.gcd(y)) * y).abs();
}