Update gcd.md
This commit is contained in:
@ -8,9 +8,9 @@ Otherwise, return the GCD of `y` and the remainder of the division `x/y`.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const gcm = (...arr) => {
|
const gcm = (...arr) => {
|
||||||
arr = [].concat(...arr)
|
let data = [].concat(...arr)
|
||||||
const helperGcd = (x, y) => (!y ? x : gcd(y, x % y));
|
const helperGcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||||
return arr.reduce((a, b) => helperGcd(a, b))
|
return data.reduce((a, b) => helperGcd(a, b))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user