Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def sieve_of_eratosthenes(limit):
  4.     is_prime = np.ones(limit + 1, dtype=np.bool)
  5.     is_prime[[0, 1]] = False
  6.     for i in range(2, limit + 1):
  7.       if is_prime[i]:
  8.         is_prime[np.arange(i * i, limit + 1, i)] = False
  9.     return np.where(is_prime)[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement