LC 0263 [E] Ugly Number - ALawliet/algorithms GitHub Wiki

class Solution:
    def isUgly(self, num):
        if num <= 0:
            return False
        
        for x in [2, 3, 5]:
            while num % x == 0:
                num = num // x
                
        return num == 1