본문 바로가기
Leetcode

[LeetCode] Ugly Number 파이썬

by YGSEO 2021. 4. 11.
728x90
class Solution:
    # @param {integer} num
    # @return {boolean}
    def isUgly(self, num):
        if num == 0:
            return False
        for i in [2, 3, 5]:
            while num % i == 0:
                num /= i
        return num == 1

 

728x90

댓글