prevPow - nodef/extra-math GitHub Wiki

Find largest power-of-n less than or equal to given number.

Similar: isPow, prevPow, nextPow.

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


xmath.prevPow(35, 2);
// → 32

xmath.prevPow(35, 4);
// → 16

xmath.prevPow(35, 3);
// → 27

References