Package g0201_0300.s0204_count_primes
Class Solution
java.lang.Object
g0201_0300.s0204_count_primes.Solution
204 - Count Primes.<p>Medium</p>
<p>Given an integer <code>n</code>, return <em>the number of prime numbers that are strictly less than</em> <code>n</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 10</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> There are 4 prime numbers less than 10, they are 2, 3, 5, 7.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 0</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> n = 1</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= n <= 5 * 10<sup>6</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countPrimes
public int countPrimes(int n)
-