mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-12 13:54:31 +00:00
7 lines
138 B
C
7 lines
138 B
C
// Without loops/recursion.
|
|
// Runtime: O(1)
|
|
// Space: O(1)
|
|
bool isPowerOfTwo(int n){
|
|
return (n > 0) && ((n & (n - 1)) == 0);
|
|
}
|