mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-08 19:06:00 +00:00
* Get Bit: Make more terse * Power of two: Allowed 1 as a valid power of 2. Power of two: Removed unnecessary exception throwing. * Fisher Yates: Made more terse * Least Common Multiple: Fill undefined value * Greatest Common Divisor: Fill undefined value. Greatest Common Divisor: Make more terse.
12 lines
286 B
JavaScript
12 lines
286 B
JavaScript
import euclideanAlgorithm from '../euclidean-algorithm/euclideanAlgorithm';
|
|
|
|
/**
|
|
* @param {number} a
|
|
* @param {number} b
|
|
* @return {number}
|
|
*/
|
|
|
|
export default function leastCommonMultiple(a, b) {
|
|
return ((a === 0) || (b === 0)) ? 0 : Math.abs(a * b) / euclideanAlgorithm(a, b);
|
|
}
|