Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 10**6 + 3 * 10**5
- is_prime = [True] * (x + 1)
- is_prime[0] = is_prime[1] = False
- p = 2
- while p * p <= x:
- if is_prime[p]:
- for i in range(p*p, x+1, p):
- is_prime[i] = False
- p += 1
- k = 0
- for i in range(x+1):
- k += is_prime[i]
- print(k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement