DEV Community

Discussion on: Infinite list of prime numbers using Python generators

Collapse
 
orenovadia profile image
orenovadia

Since the time complexity of is_prime is O(sqrt(n)):
Worth a mention that for prime numbers up to N, overall, using this method is not as time efficient as sieve methods that eagerly pre-calculate all the primes up to N (this is because sieves use previously found primes to eliminate other composite numbers, instead of performing an exhaustive search for each number).