CT072

Sieve of Eratosthenes

EasyAcceptance: 0.0%

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:

Input: 30
Output: 2 3 5 7 11 13 17 19 23 29

Example 2:

Input: 10
Output: 2 3 5 7

Constraints:

2 <= n <= 10^6

Tags:

math sieve prime-numbers
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki