Skip to content

prevPow

Subhajit Sahu edited this page Aug 9, 2022 · 2 revisions

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 xnumber = require('extra-number');


xnumber.prevPow(32, 2);
// → 32

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

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


References

Clone this wiki locally