Ugly Number

Easy · Math & Number Theory · about 5 minutes

Asked at Google, Amazon, Bloomberg, Microsoft, Meta.

Decide whether n is *ugly*: a positive integer with no prime factor other than 2, 3 or 5. The number 1 is ugly; 0 and negative numbers are not.