Avatar ·

Quick methods of finding all prime numbers less than n

📁 Advanced Python Topics, question, numpy, AI

What are the fastest known algorithms for finding all prime numbers less than n:

and what are the quick implementations in Python, Numpy, etc.)?

   def   eratosthenes2  ( n ):  multiples =  set  ()   for  i  range  ( 2 , n+ 1 ):   if  i  not   in  multiples:   yield  i multiples.update ( range  (i*i, n+ 1 , i))