Skip to content

Files

Latest commit

 Cannot retrieve latest commit at this time.

History

History
12 lines (12 loc) · 312 Bytes

263. Ugly Number.md

File metadata and controls

12 lines (12 loc) · 312 Bytes

263. Ugly Number(Easy)

[tag] prime number

  • devide all prime numbers if divisible, and return n == 1.
class Solution:
    def isUgly(self, n: int) -> bool:
        if n <= 0: return False
        for p in [2, 3, 5]:
            while n % p == 0:
                n = n // p
        return n == 1