JuniorMath

Ugly Number

An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.

Given an integer n, return true if n is an ugly number.

Example 1
Inputn = 6
Outputtrue
6 = 2 × 3.
Example 2
Inputn = 1
Outputtrue
1 has no prime factors.

Constraints

  • -2^31 <= n <= 2^31 - 1

Asked at 7 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate