An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return true if n is an ugly number.

Input: 6 → Output: true (6 = 2 * 3)Input: 14 → Output: false (14 = 2 * 7)

Divide out all factors of 2, 3, and 5. If result is 1, n is ugly.

class Solution { public boolean isUgly(int n) { if (n <= 0) return false; for (int f : new int[]{2,3,5}) while (n % f == 0) n /= f; return n == 1; } }