Java clear solution


  • 0

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

    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.