isPow - nodef/extra-math GitHub Wiki

Check if a number is a power-of-n.

Similar: isPow, prevPow, nextPow.

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


xmath.isPow(32, 2);
// → true

xmath.isPow(32, 4);
// → false

xmath.isPow(64, 4);
// → true

References