题目链接:https://leetcode.com/problems/power-of-two
Given an integer, write a function to determine if it is a power of two.
Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.
class Solution {
public:
bool isPowerOfTwo(int n) {
bool a;
if(n==0)
a=false;
else if(n==1)
a=true;
else if(n%2!=0)
{
a=false;
}
else
{
a=isPowerOfTwo(n/2);
}
return a;
}
};