mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-07-26 10:52:55 +00:00
7 lines
112 B
C
7 lines
112 B
C
bool isPowerOfTwo(int n)
|
|
{
|
|
if (!n)
|
|
return false;
|
|
while (n % 2 == 0) n /= 2;
|
|
return n == 1;
|
|
} |