mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
5 lines
104 B
C
5 lines
104 B
C
bool isPowerOfTwo(int n){
|
|
if (! n) return false;
|
|
while (n % 2 == 0) n /= 2;
|
|
return n == 1;
|
|
} |