LeetCode 263. Ugly Number Posted on 2021-04-10 Edited on 2024-11-24 In LeetCode 1234567891011class Solution {public: bool isUgly(int n) { if (n <= 0) return false; int factors[] = {2, 3, 5}; for (int factor : factors) while (n % factor == 0) n /= factor; return n == 1; }};