5 lines
145 B
JavaScript
5 lines
145 B
JavaScript
const gcd = (...arr) => {
|
|
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
|
return [...arr].reduce((a, b) => _gcd(a, b));
|
|
};
|
|
module.exports = gcd |