Sieve of Eratosthenes - Optimized
Build an optimized solution of implementing the Sieve of Eratosthenes.
We'll cover the following
Can we still do better than our previous code?
Definitely! Here, we don’t need to check for even numbers. Instead of starting the second loop from 2p
, we can start from . Have a look at the code below.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.