# 计数质数

<p>统计所有小于非负整数&nbsp;<em><code>n</code>&nbsp;</em>的质数的数量。</p>

<p>&nbsp;</p>

<p><strong>示例 1：</strong></p>

<pre><strong>输入：</strong>n = 10
<strong>输出：</strong>4
<strong>解释：</strong>小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。
</pre>

<p><strong>示例 2：</strong></p>

<pre><strong>输入：</strong>n = 0
<strong>输出：</strong>0
</pre>

<p><strong>示例 3：</strong></p>

<pre><strong>输入：</strong>n = 1
<strong>输出</strong>：0
</pre>

<p>&nbsp;</p>

<p><strong>提示：</strong></p>

<ul>
	<li><code>0 &lt;= n &lt;= 5 * 10<sup>6</sup></code></li>
</ul>


## template

```python

class Solution:
    def countPrimes(self, n: int) -> int:

        is_prime = [1] * n

        count = 0
        for i in range(2, n):

            if is_prime[i]:
                count += 1

                for j in range(i * i, n, i):
                    is_prime[j] = 0

        return count
```

## 答案

```python

```

## 选项

### A

```python

```

### B

```python

```

### C

```python

```