# 263. Ugly Number

[Write a program to check whether a given number is an ugly number. Ugly numbers are **positive numbers** whose prime factors only include `2, 3, 5`.](https://leetcode.com/problems/ugly-number/)

```java
class Solution {
    public boolean isUgly(int num) {
        // 1 is ugly number
        // if ugly number is larger than one: it must be dividable by 2, 3 or 5
        return dfs(num);
    }
    
    private boolean dfs(int num){
        if (num==1){
            return true;
        }else if(num<1){
            return false;
        }
        
        if (num%2==0){
            return dfs(num>>1);
        }else if (num%3==0){
            return dfs(num/3);
        }else if (num%5==0){
            return dfs(num/5);
        }else{
            return false;
        }
    }
}
```
