Ugly Number

public class Solution {
    public bool IsUgly(int num) {
        if(num <=0) return false;
        if(num==1) return true;
        while(num/2*2==num){
            num = num/2;
        }
        while(num/3*3==num){
            num = num/3;
        }
        while(num/5*5==num){
            num = num/5;
        }
        return num==1?true:false;
    }
}

 

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