package leetcode;

/**
 * https://leetcode.com/problems/ugly-number/
 */
public class Problem263 {
    public boolean isUgly(int num) {
        return false;
    }
    
    public static void main(String[] args) {
        Problem263 prob = new Problem263();
        System.out.println(prob.isUgly(6)); // true
        System.out.println(prob.isUgly(8)); // true
        System.out.println(prob.isUgly(14)); // false
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -174,24 +174,52 @@
 (int num) %7B%0A
+        if (num == 0) %7B%0A    
         retu
@@ -228,16 +228,20 @@
  false;%0A
+    
     %7D%0A  
@@ -246,255 +246,824 @@
     
-%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem263 prob = new Problem263();%0A        System.out.println(prob.isUgly(6)); // true%0A        System.out.println(prob.isUgly(8)); // true%0A        System.out.println(prob.isUgly(14)); // false
+if (num == 1) %7B%0A            return true;%0A        %7D%0A        int%5B%5D primes = new int%5B%5D%7B2, 3, 5%7D;%0A        Set%3CInteger%3E pf = new HashSet%3C%3E();%0A        isUgly(num, primes, pf);%0A        for (int prime : primes) %7B%0A            pf.remove(prime);%0A        %7D%0A        return pf.isEmpty();%0A    %7D%0A    %0A    private void isUgly(int num, int%5B%5D primes, Set%3CInteger%3E pf) %7B%0A        for (int prime : primes) %7B%0A            if (num == prime) %7B%0A                pf.add(prime);%0A                return;%0A            %7D%0A        %7D%0A        boolean found = false;%0A        for (int prime : primes) %7B%0A            if (num %25 prime == 0) %7B%0A                pf.add(prime);%0A                isUgly(num / prime, primes, pf);%0A                found = true;%0A                break;%0A            %7D%0A        %7D%0A        if (!found) %7B%0A            pf.add(num);%0A        %7D
 %0A   

Solve problem 263