263. Ugly Number

# Easy

Solution is interesting. Conditions should be careful.

class Solution:
    def isUgly(self, num: int) -> bool:
        while num >= 2 and num%2 == 0:
            num = num//2
        while num >= 3 and num%3 == 0:
            num = num//3
        while num >= 5 and num%5 == 0:
            num = num//5
        
        if num == 1:
            return True
        else:
            return False

Last updated