Power of Two Check
Return True if n is a power of two ( for some integer ).
Requirements
- One expression: a power of two has exactly one set bit, so
n & (n - 1) == 0.
Examples
EXAMPLE WALKTHROUGHtwo to the zero
A guided view of the published example, not a trace of your code.
INPUT
[1]TASKpower_of_two_check()
EXPECTED OUTPUT
trueStart with the input values shown in this example.
Example 1 of 3
Input: n = 1
Output: true
Explanation: two to the zero
Input: n = 16
Output: true
Explanation: sixteen
Input: n = 3
Output: false
Explanation: not a power
Hint 1
Remember to reject n <= 0.