Checking if a number is power of two in Julia – ispow2() Method
Last Updated :
01 Apr, 2020
The ispow2()
is an inbuilt function in julia which is used to test whether the specified number n is a power of two or not.
Syntax: ispow2(n::Integer)
Parameters:
- n::Integer: Specified number.
Returns: It returns true if the given number is power of 2 else false.
Example 1:
println(ispow2( 1 ))
println(ispow2( 2 ))
println(ispow2( 4 ))
println(ispow2( 8 ))
|
Output:
true
true
true
true
Example 2:
println(ispow2( 3 ))
println(ispow2( 5 ))
println(ispow2( 7 ))
println(ispow2( 9 ))
|
Output:
false
false
false
false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...