Easy · Math
Power of two
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
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.