-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path204.py
43 lines (35 loc) · 977 Bytes
/
204.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Solution(object):
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
Zlst = []
for i in range(1000):
#print(i,Zlst)
if i==0:
Zlst.append(0)
continue
if i==1:
Zlst.append(0)
continue
flag=0
for j in range(i):
#print(i,j)
if j==0 or j==1:
continue
if i%j==0:
flag=1
#print('there is a',i,j)
if flag==0:
Zlst.append(1)
else:
Zlst.append(0)
#print(Zlst)
count=0
for i in range(n):
count = count + Zlst[i]
return count
if __name__=='__main__':
sl =Solution()
print(sl.countPrimes(11))