Ctrl K

Only Fours Multiplied

Easy
You are given an integer n. Return True if n equals 4ᵏ for some integer k ≥ 0, and False otherwise. With a loop it is easy; try to do it without loops or recursion.
Example 1
n=64 → True

64 = 4 · 4 · 4 = 4³.

Example 2
n=8 → False

8 is a power of two but not of four: 4¹ = 4 and 4² = 16.

Example 3
n=1 → True

1 = 4⁰.

Constraints
  • -2³¹ ≤ n ≤ 2³¹ - 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsOnly Twos 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=64
Expected
True

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