【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)

posted @ 2016-10-12 17:08  火金队长  阅读(165)  评论(0编辑  收藏  举报