This is a slow solution but different from what I have seen.

The if statements are really unnecessary, however it could save some time.

It also can be recursive.

again, it is SLOW but another solution.

```
public class Solution {
public boolean isUgly(int num) {
if(num<1)
return false;
String s="";
if(num>1&&num%2==0) {
s=Integer.toBinaryString(num).replaceAll("0+$", "");
num=Integer.valueOf(s, 2);
// return isUgly(num);
}
if(num>1&&num%3==0) {
s=Integer.toString(num, 3).replaceAll("0+$", "");
num=Integer.valueOf(s, 3);
// return isUgly(num);
}
if(num>1&&num%5==0) {
s=Integer.toString(num, 5).replaceAll("0+$", "");
num=Integer.valueOf(s, 5);
// return isUgly(num);
}
return num==1;
}
}
```