-
Notifications
You must be signed in to change notification settings - Fork 646
Expand file tree
/
Copy path203.py
More file actions
22 lines (18 loc) 路 529 Bytes
/
Copy path203.py
File metadata and controls
22 lines (18 loc) 路 529 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution(object):
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
if n < 2:
return 0
A = [0] * (n + 1)
count = 0
for pointer1 in range(2, n):
if A[pointer1] == 0:
count += 1
pointer2 = pointer1
while (pointer2 + pointer1 < n):
pointer2 += pointer1
A[pointer2] = 1
return count