Answers for "Least common multiple from array"

0

Least common multiple from array

const lcm = (...arr) => {
  const gcd = (x, y) => (!y ? x : gcd(y, x % y));
  const _lcm = (x, y) => (x * y) / gcd(x, y);
  return [...arr].reduce((a, b) => _lcm(a, b));
};
Posted by: Guest on April-26-2022

Code answers related to "Least common multiple from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language