nextpow(a, x)

The smallest a^n not less than x, where n is a non-negative integer. a must be greater than 1, and x must be greater than 0.


julia> nextpow(2, 10)

In this example, the function nextpow returns the smallest power of 2 (a) that is not less than 10 (x). The output is 4, as 2 raised to the power of 4 is 16, which is greater than 10.

julia> nextpow(3, 50)

Here, the function nextpow calculates the smallest power of 3 (a) that is not less than 50 (x). The output is 4, as 3 raised to the power of 4 is 81, which is greater than 50.

julia> nextpow(10, 1000)

In this example, the function nextpow determines the smallest power of 10 (a) that is not less than 1000 (x). The output is 3, as 10 raised to the power of 3 is 1000, which is equal to 1000.

Common mistake example:

julia> nextpow(0, 5)
ERROR: DomainError with 0.0:
Argument 0.0 to exponentiate must be greater than zero

This example shows an error that occurs when the value of a is less than or equal to 1. The a value must be greater than 1 for the nextpow function to work correctly.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: