class Solution {
public:
bool isUgly(int num) {
if(num<=0)
{
return false;
}
if(num==1)
{
return true;
}
while(num!=1)
{
if(num%2==0)
{
num/=2;
continue;
}
if(num%3==0)
{
num/=3;
continue;
}
if(num%5==0)
{
num/=5;
continue;
}
else
{
return false;
}
}
return true;
}
};
LeetCode:263.丑数
最新推荐文章于 2022-08-08 13:56:09 发布