204. Count Primes

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)