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.
Divide out all factors of 2, 3, and 5. If result is 1, n is ugly.
- If n <= 0: return false.
- While n divisible by 2: n /= 2.
- While n divisible by 3: n /= 3.
- While n divisible by 5: n /= 5.
- Return n == 1.
- Time Complexity: O(log N)
- Space Complexity: O(1)