263. Ugly Number

263. Ugly Number_第1张图片

Java

public class Solution {
    public boolean isUgly(int num) {
        if(num==0) return false;
        while(num%2==0)
        {
            num=num/2;
        }
        while(num%3==0)
        {
            num=num/3;
        }
        while(num%5==0)
        {
            num=num/5;
        }
        if(num==1) return true;
        else return false;
    }
}

你可能感兴趣的:(263. Ugly Number)