Archive, multitagging, cleanup
Cleaned up the current snippets for consistency and minor problems, added multiple tags to most of them, archived a few.
This commit is contained in:
@ -9,10 +9,11 @@ Otherwise, return the GCD of `y` and the remainder of the division `x/y`.
|
||||
```js
|
||||
const gcd = (...arr) => {
|
||||
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||
return [].concat(...arr).reduce((a, b) => _gcd(a, b));
|
||||
return [...arr].reduce((a, b) => _gcd(a, b));
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
gcd(8, 36); // 4
|
||||
gcd(...[12,8,32]); // 4
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user