Ctrl K

Only Twos Multiplied

Easy
You are given an integer n. Return True if n equals 2ᵏ for some integer k ≥ 0, and False otherwise. Try to solve it without loops or recursion.
Example 1
n=32 → True

32 = 2⁵.

Example 2
n=1 → True

1 = 2⁰.

Example 3
n=12 → False

12 = 4 · 3, and the factor 3 spoils it.

Constraints
  • -2³¹ ≤ n ≤ 2³¹ - 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsOnly Fours Multiplied EasyA String That Copies Itself EasyDoubling Rows of Bits MediumA Letter in a Growing Word HardSum of Binary Strings Easy
loading Python…
Input
n=32
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.