263. Ugly Number
Input: 6
Output: true
Explanation: 6 = 2 × 3Input: 8
Output: true
Explanation: 8 = 2 × 2 × 2Input: 14
Output: false
Explanation: 14 is not ugly since it includes another prime factor 7.bool isUgly(int num) {
if (num <= 0) return false;
vector<int> factor = {2, 3, 5};
for (int f : factor) {
while (num % f == 0) num /= f;
}
return num == 1;
}Last updated