Given an integer n, return true if it is a power of four, and false otherwise. An integer n is a power of four if there is an integer x such that n == 4^x. Follow up: can you solve it without loops or recursion?
Given an integer n, return true if it is a power of four, and false otherwise. An integer n is a power of four if there is an integer x such that n == 4^x. Follow up: can you solve it without loops or recursion?
Example 1:
Input: {"n":16}
Output: true
Constraints:
−231≤n≤231−1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":16}
Is 16 a power of four? Powers of four are 1, 4, 16, 64, ... and in binary each is a single 1 followed by an even number of 0s.