FunctionRacerProblemsRace

Ugly Number

EasyMathPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems