javascript-algorithms icon indicating copy to clipboard operation
javascript-algorithms copied to clipboard

Least Common Multiple for a array of elements.

Open abhiphile opened this issue 1 year ago • 6 comments

It will be better to also have a leastCommonMultiple function for an array where I could pass an array of elements and get the result.

export default function leastCommonMultiple(a, b) {
  return ((a === 0) || (b === 0)) ? 0 : Math.abs(a * b) / euclideanAlgorithm(a, b);
}

abhiphile avatar Jul 20 '24 10:07 abhiphile