Ugly Number

Easy

Company Tags

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

You are given an integer n, return true if n is an ugly number.

Example 1:

Input: n = 4

Output: true

Explanation: 4 = 2 * 2.

Example 2:

Input: n = 1

Output: true

Explanation: 1 has no prime factors.

Example 3:

Input: n = 11

Output: false

Explanation: 11 is a prime number.

Constraints:

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


Company Tags

Please upgrade to NeetCode Pro to view company tags.

n =