Skip to content

prevPow

Subhajit Sahu edited this page Aug 8, 2022 · 1 revision

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

Clone this wiki locally