Search⌘ K

Sieve of Eratosthenes

Explore how to generate prime numbers efficiently using the Sieve of Eratosthenes. Understand its steps, implementation, and time complexity to find all primes up to any number N. This lesson guides you through marking multiples and optimizing prime checks for improved performance in competitive programming.

We'll cover the following...

Generating primes

Given an integer NN, you are asked to print all the prime numbers between 11 and NN.

Using what we have discussed so far, one way to do this would be to iterate over all the numbers from 11 to NN and check if it’s prime or not.

Time Complexity - O(NN).O(N*\sqrt{N}).

It should be okay for NN up to ...