Decide whether n is an exact power of two (1, 2, 4, 8, 16, ...).
Input format
One line: a positive integer n.
Output format
Print YES if n is a power of two, otherwise NO.
Constraints
- 1 <= n <= 1000000000000000000
Decide whether n is an exact power of two (1, 2, 4, 8, 16, ...).
One line: a positive integer n.
Print YES if n is a power of two, otherwise NO.
Example 1
Input
16
Expected
YES
Explanation
16 = 2^4 is a power of two, so YES.
Example 2
Input
6
Expected
NO
Explanation
6 = 2*3 is not a power of two, so NO.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →