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.


Follow up: Could you solve it without loops/recursion?

Credits:Special thanks to @yukuairoy  for adding this problem and creating all test cases.

Difficulty: introductory

Starter code:

class Solution:
    def isPowerOfFour(self, num: int) -> bool:
        

Solutions:
class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         return num != 0 and num & (num -1) == 0 and num & 0x55555555 == num

class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         if num == 0:
             return False
         return not num & (num - 1) and len(bin(num)) % 2 == 1

class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         if num < 1:
             return False
         return  (num - 1) & num == 0 and num & 0x55555555 != 0

class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         
         if num <= 0:
             return False
         
         import math
         i = math.log10(num) / math.log10(4)
         return i.is_integer()

class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         return num != 0 and not num & (num - 1) and len(bin(num)) % 2 == 1

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


class Solution:
     def isPowerOfFour(self, num):
         return bin(num).count('1')==1 and bin(num).count('0')%2==1 and num>0

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


class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         if num == 1:
             return True
 
         target = 1
         while target < num:
             target *= 4
             if target == num:
                 return True
 
         return False

class Solution:
     def isPowerOfFour(self, num):
         """
         :type num: int
         :rtype: bool
         """
         if num <= 0:
             return False
         sqrt_root = math.sqrt(num)
         if math.floor(sqrt_root) == sqrt_root:
             return int(sqrt_root) & int(sqrt_root - 1) == 0
         return False