https://leetcode.com/problems/ugly-number/
class Solution { public: bool isUgly(int num) { if(num<=0) return false; if(num==1) return true; int temp=num; bool flag=true; while(temp!=1) { if(isPrime(temp,2)==true) temp/=2; else if(isPrime(temp,3)==true) temp/=3; else if(isPrime(temp,5)==true) temp/=5; else { flag=false; break; } } return flag; } bool isPrime(int a,int b) { if(a/b*b==a) return true; else return false; } };