Update lcm.md

This commit is contained in:
Angelos Chalaris
2017-12-29 13:12:01 +02:00
committed by GitHub
parent 7c6541366d
commit 6e7e9c5996

View File

@ -7,10 +7,10 @@ The GCD formula uses recursion.
```js
const lcm = (...arr) => {
let data = [].concat(...arr)
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
const helperLcm = (x, y) => x * y / gcd(x, y);
return arr.reduce((a, b) => helperLcm(a, b))
let data = [].concat(...arr);
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
const helperLcm = (x, y) => x * y / gcd(x, y);
return arr.reduce((a, b) => helperLcm(a, b))
}
```