Ugly Number

Given an integer n, determine whether it is an ugly number. An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.

Input Format

n = integer

Output Format

true if n is ugly, otherwise false

Constraints

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

Examples

Example 1:

Input:

n = 6

Output:

true

Explanation:

6 = 2 × 3, so it is ugly.

Example 2:

Input:

n = 14

Output:

false

Explanation:

14 has prime factor 7, so it is not ugly.

Loading...
Ugly Number - Math DSA Problem