root - nodef/extra-bigint GitHub Wiki

Find the nth root of a bigint.

Similar: sqrt, cbrt, root.

function root(x, n)
// x: a bigint
// n: nth root (1n)
const xbigint = require('extra-bigint');


xbigint.root(25n, 2n);
// → 5n

xbigint.root(-8n, 3n);
// → -2n

xbigint.root(81n, 4n);
// → 3n

xbigint.root(99n, 4n);
// → 3n

References