nextPow - nodef/extra-math GitHub Wiki

Find smallest power-of-n greater than or equal to given number.

Similar: isPow, prevPow, nextPow.

function nextPow(x, n)
// x: a number
// n: base
const xmath = require('extra-math');


xmath.nextPow(29, 2);
// → 32

xmath.nextPow(29, 4);
// → 64

xmath.nextPow(29, 3);
// → 81

References