Problem
Return true if the integer n is a power of two (1, 2, 4, 8, ...), otherwise false. Try to do it without a loop.
Example 1
- Input
- n = 16
- Output
- true
- Why
- 2^4
Example 2
- Input
- n = 1
- Output
- true
- Why
- 2^0
Example 3
- Input
- n = 6
- Output
- false
Example 4
- Input
- n = 0
- Output
- false
Constraints
-2^31 <= n <= 2^31 - 1