leetcode 263. 丑数

263. 丑数

在这里插入图片描述

class Solution {
public:
    bool isUgly(int n) {
        if(n <= 0) return false;
        while(n % 2 == 0 || n % 3 == 0 || n % 5 == 0) {
            if(n % 2 == 0) n /= 2;
            if(n % 3 == 0) n /= 3;
            if(n % 5 == 0) n /= 5;
        }
        return n == 1;
    }
};