mirror of
https://github.com/TheAlgorithms/C
synced 2025-05-14 07:58:04 +03: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;
|
|
} |