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.醜數
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.