【leetcode❤python】342. Power of Four

#-*- coding: UTF-8 -*-
class Solution(object):
    def isPowerOfFour(self, num):
        """
        :type num: int
        :rtype: bool
        """
        if num<=0:return False
        while True:
            if num==1:return True
            num,mod=divmod(num,4)
            if mod!=0:
                return False
        
sol=Solution()
print sol.isPowerOfFour(5)

原文地址:https://www.cnblogs.com/kwangeline/p/5953639.html