Power of Two

Published by Helen Yu in

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

Examples

powerOfTwo(32) ➞ true

powerOfTwo(1) ➞ true

powerOfTwo(-7) ➞ false

powerOfTwo(18) ➞ false

Notes

N/A

Watch a quick demo on how Edabit works.