Files
30-seconds-of-code/test/gcd/gcd.js

4 lines
134 B
JavaScript

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