Package g0201_0300.s0263_ugly_number
Class Solution
java.lang.Object
g0201_0300.s0263_ugly_number.Solution
263 - Ugly Number.<p>Easy</p>
<p>An <strong>ugly number</strong> is a positive integer whose prime factors are limited to <code>2</code>, <code>3</code>, and <code>5</code>.</p>
<p>Given an integer <code>n</code>, return <code>true</code> <em>if</em> <code>n</code> <em>is an <strong>ugly number</strong></em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 6</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> 6 = 2 × 3</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 8</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> 8 = 2 × 2 × 2</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 14</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> 14 is not ugly since it includes the prime factor 7.</p>
<p><strong>Example 4:</strong></p>
<p><strong>Input:</strong> n = 1</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>-2<sup>31</sup> <= n <= 2<sup>31</sup> - 1</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isUgly
public boolean isUgly(int n)
-