Open In App

Calculating smallest and largest a<sup>n</sup> in Julia – nextpow() and prevpow() Methods

The nextpow() is an inbuilt function in julia which is used to return the smallest not less than x, where n is a non-negative integer, a must be greater than 1, and x must be greater than 0.
Syntax: nextpow(a, x) Parameters:
  • a: Specified number greater than 1.
  • x: Specified number greater than 0.
Returns: It returns the smallest .
Example:
# Julia program to illustrate 
# the use of nextpow() method
   
# Getting the smallest a ^ n
println(nextpow(2, 8))
println(nextpow(2, 10))
println(nextpow(3, 8))
println(nextpow(5, 15))

                    
Output:
8
16
9
25

prevpow()

The prevpow() is an inbuilt function in julia which is used to return the largest not greater than x, where n is a non-negative integer, a must be greater than 1, and x must not be less than 1.
Syntax: prevpow(a, x) Parameters:
  • a: Specified number greater than 1.
  • x: Specified number must not be less than 1.
Returns: It returns the largest .
Example:
# Julia program to illustrate 
# the use of prevpow() method
   
# Getting the largest a ^ n
println(prevpow(2, 8))
println(prevpow(2, 6))
println(prevpow(3, 8))
println(prevpow(5, 15))

                    
Output:
8
4
3
5

Article Tags :