
丑数的因子只能是2,3,5。但是可能有多个2,多个3,多个5.因此需要循环地除以2、3、5.
public class Solution {
public bool IsUgly(int n) {
if (n <= 0) {
return false;
}
int[] factors = {2, 3, 5};
for ( int i=0;i<3;i++) {
int factor=factors[i];
while (n % factor == 0) {
n /= factor;
}
}
return n == 1;
}
}


![[Vulfocus解题系列]spring 命令执行(CVE-2022-22947)](https://img-blog.csdnimg.cn/direct/241790510f4f47aebc0655f0bfac8157.png)















