> For the complete documentation index, see [llms.txt](https://rachel2011.gitbook.io/leetcode_cc150/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rachel2011.gitbook.io/leetcode_cc150/leetcode/power-of-four.md).

# Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

**Example:**\
Given num = 16, return true. Given num = 5, return false.

```
class Solution(object):
    def isPowerOfFour(self, num):
        """
        :type num: int
        :rtype: bool
        """
        while num and num%4 == 0:
            num = num/4
        if num ==1:
            return True
        return False
```

```
class Solution(object):
    def isPowerOfFour(self, num):
        """
        :type num: int
        :rtype: bool
        """
        return num>0 and (math.log10(num)/math.log10(4))%1 ==0
```
