+ 1
Powerof2
What are power of 2? And how to check if the number is power of2?
2 Answers
+ 12
divide the number by 2 repeatedly if n%2 comes out to be 0
//if n comes out to be 1 at last , then it is 2^x form else its not 2^x form
+ 4
technically everything is a power of 2(instead of negative numbers[not talking about complex numbers]) to find the power Use log and check if the result is an integer. if it is then its a power of 2(2^1,2^2,...2^n) while n is an integer. otherwise its not an integer