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).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since the time complexity of
is_prime
isO(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 toN
(this is because sieves use previously found primes to eliminate other composite numbers, instead of performing an exhaustive search for each number).