Is Power of Two
EasyMathBit Manipulation
Description
Given an integer n, return true if it is a power of two, and false otherwise.
Examples
Input:
n = 16Output:
trueExplanation:
16 can be written as two raised to a whole-number power.
Input:
n = 6Output:
falseExplanation:
6 cannot be written as two raised to a whole-number power.
Input:
n = 1Output:
trueExplanation:
1 can be written as two raised to a whole-number power.
Constraints
- •
-10⁹ ≤ n ≤ 10⁹