【leetcode❤python】263. Ugly Number

class Solution(object):
    def isUgly(self, num):
        if num<=0:return False
        comlist=[2,3,5];modflag=0
        
        while True:

            if num==1:break
            for value in comlist:
                tuple=divmod(num,value)
                if tuple[1]==0:
                    modflag=1;num=tuple[0]
                    break
            if modflag==0:return False
            modflag=0
        
        return True
                    


sol=Solution()
print sol.isUgly(1)

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