Participate in Codex, Test Your Skills & Win BIG

Power of 2

Find if Given number is power of 2 or not.
More specifically, find if given number can be expressed as 2^k where k >= 1.


number length can be more than 64, which mean number can be greater than 2 ^ 64 (out of long long range)


return 1 if the number is a power of 2 else return 0


Input : 128
Output : 1
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Power of 2 on Interview Code Editor
  • Hint 1
  • Solution Approach
  • Complete Solution
Asked In:


Click here to start solving coding interview questions