Travis build: 483
This commit is contained in:
@ -11,7 +11,7 @@ const gcd = (...arr) => {
|
||||
let data = [].concat(...arr);
|
||||
const helperGcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||
return data.reduce((a, b) => helperGcd(a, b));
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
@ -10,11 +10,11 @@ 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))
|
||||
}
|
||||
return arr.reduce((a, b) => helperLcm(a, b));
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
lcm(12, 7); // 84
|
||||
lcm([1,3,4],5); // 60
|
||||
lcm([1, 3, 4], 5); // 60
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user