leetcode 263. Ugly Number

    bool isUgly(int num) {
        while (num < 1)
            return false;
        while (num % 2 == 0)
            num /= 2;
        while (num % 3 == 0)
            num /= 3;
        while (num % 5 == 0)
            num /= 5;
        return num == 1;
    }

 

posted on 2018-02-07 15:00  willaty  阅读(76)  评论(0编辑  收藏  举报

导航