Ugly Number
A positive integer is called ugly if its only prime factors are 2, 3 and 5. The number 1 counts as ugly.
Return True if n is ugly, and False otherwise (including when n is zero or negative).
Example 1
n 30
returns true
30 = 2 * 3 * 5.
Example 2
n 14
returns false
It has the prime factor 7.
Constraints
-231 <= n <= 231 - 1
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Water BottlesEasy
- Balanced Parentheses CountMedium
- Convert to Base Minus TwoMedium
- Count Numbers With Unique DigitsMedium
- Count PrimesMedium
- Day of the WeekMedium
- Fast PowerMedium
- Friday the 13th CountMedium