Update lcm.md

This commit is contained in:
Rohit Tanwar
2017-12-29 16:41:22 +05:30
committed by GitHub
parent 88dcf4a008
commit ea33b0bbfb

View File

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