← Back to challenges

Power of Two

PythonHardnumbersmathvalidation

Instructions

Write a function that returns True if an integer can be expressed as a power of base value 2 and False otherwise.

Examples

power_of_two(32) ➞ True

power_of_two(1) ➞ True

power_of_two(18) ➞ False

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: All Numbers in List Are Prime