Skip to content

nextPow

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

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

Clone this wiki locally