21 lines
418 B
Python
21 lines
418 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
def primes(n):
|
||
|
count = 0
|
||
|
sieve = [False]*n
|
||
|
for p in range(2, n):
|
||
|
if sieve[p]:
|
||
|
continue
|
||
|
for i in range(p**2, n, p):
|
||
|
sieve[i] = True
|
||
|
np = 2*p
|
||
|
for p2 in range(2,p+1):
|
||
|
if np >= n:
|
||
|
break
|
||
|
if not sieve[p2]:
|
||
|
count += 1
|
||
|
np += p
|
||
|
return count
|
||
|
|
||
|
print(primes(10**8))
|