Merge branch 'master' of https://github.com/kriadmin/30-seconds-of-code
This commit is contained in:
@ -7,10 +7,10 @@ The GCD formula uses recursion.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
let data = [].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))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user