204. Count Primes
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b0f4f0cdca9eab3b04dee61da0c4b595.gif)
class Solution(object):
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
if n<3:
return 0
prime=[1 for i in range(n)]
prime[0],prime[1]=0,0
ret=0
for i in range(2,int(n**0.5)+1):
if prime[i]:
ret+=1
j=2
while i*j<n:
prime[i*j]=0
j+=1
return sum(prime)