TheAlgorithms-C/leetcode/src/231.c

5 lines
104 B
C
Raw Normal View History

2019-10-29 04:06:18 +08:00
bool isPowerOfTwo(int n){
if (! n) return false;
while (n % 2 == 0) n /= 2;
return n == 1;
}