The Sieve of Eratosthenes generates all prime numbers smaller than n by iteratively marking multiples of each prime as composite. Given n, output all prime numbers less than n in ascending order, space-separated.
Example 1:
Example 2:
Constraints:
2 <= n <= 10^6
Tags: