每日一题力扣263 丑数

编写一个程序判断给定的数是否为丑数。

丑数就是只包含质因数 2, 3, 5 的正整数

不断除以2,3,5.直到等于1才是丑数

class Solution:
    def isUgly(self, num: int) -> bool:
        if num == 1:
            return True
        if num < 2:
            return False
        while num != 1:
            if num % 2 == 0:
                num /= 2
            elif num % 3 == 0:
                num /= 3
            elif num % 5 == 0:
                num /=5
            else:
                return False
        return True
原文地址:https://www.cnblogs.com/liuxiangyan/p/14511002.html