Power of Four - Problem
Given an integer n, return true if it is a power of four. Otherwise, return false.
An integer n is a power of four if there exists an integer x such that n == 4x.
Input & Output
Example 1 — Power of Four
$
Input:
n = 16
›
Output:
true
💡 Note:
16 = 4², so it is a power of four
Example 2 — Not a Power of Four
$
Input:
n = 5
›
Output:
false
💡 Note:
5 cannot be expressed as 4^x for any integer x
Example 3 — Edge Case
$
Input:
n = 1
›
Output:
true
💡 Note:
1 = 4⁰, so it is a power of four
Constraints
- -2³¹ ≤ n ≤ 2³¹ - 1
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code