Files
30-seconds-of-code/test/gcd/gcd.js
2018-08-02 13:49:33 +03:00

6 lines
150 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;