image.png

    1. public boolean isUgly(int num) {
    2. if(num==0)
    3. return false;
    4. while(num%2==0)
    5. num/=2;
    6. while(num%3==0)
    7. num/=3;
    8. while(num%5==0)
    9. num/=5;
    10. return num==1;
    11. }