Easy · Math
Power of Two (Math)
Given an integer n, return true if n is a power of two (n = 2^k for some integer k ≥ 0), and false otherwise.
Examples
Example 1
n = 16 (power of two)Output: 16 is a power of two
Example 2
n = 6 (not power of two)Output: 6 is not a power of two
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.