Loading content...
Given an integer n, determine whether it represents a perfect quadruple power—that is, whether n can be expressed as 4 raised to some non-negative integer exponent.
Formally, return true if there exists an integer k where k ≥ 0 such that n = 4^k. Otherwise, return false.
A quadruple power is defined as any value in the sequence: 1, 4, 16, 64, 256, 1024, ... where each subsequent value is obtained by multiplying the previous value by 4.
Your task is to design an efficient algorithm that determines membership in this specific numerical sequence.
n = 16true16 can be expressed as 4² (4 raised to the power of 2), which equals 16. Therefore, 16 is a valid quadruple power.
n = 5false5 cannot be expressed as 4 raised to any non-negative integer power. The quadruple powers near 5 are 4¹ = 4 and 4² = 16, and 5 does not equal either.
n = 1true1 can be expressed as 4⁰ (4 raised to the power of 0), which equals 1. By definition, any positive number raised to the power of 0 equals 1.
Constraints