gcd - nodef/extra-bigint GitHub Wiki

Find the greatest common divisor of bigints.

Similar: gcd, lcm.

function gcd(...xs)
// xs: a list of bigints
const xbigint = require('extra-bigint');


xbigint.gcd(6n, 15n);
// → 3n

xbigint.gcd(6n, 15n, 21n);
// → 3n

xbigint.gcd(6n, 15n, 20n);
// → 1n

References