#C12639. Sieve of Eratosthenes: Prime Number Generator

    ID: 42088 Type: Default 1000ms 256MiB

Sieve of Eratosthenes: Prime Number Generator

Sieve of Eratosthenes: Prime Number Generator

In this problem, you are given a single non-negative integer ( n ). Your task is to generate all prime numbers less than or equal to ( n ) using the Sieve of Eratosthenes algorithm. This classic algorithm works in ( O(n \log\log n) ) time and is efficient for generating a list of primes.

For example, if ( n = 10 ), the prime numbers are: 2, 3, 5, 7.

inputFormat

The input consists of a single line containing one non-negative integer ( n ) (( 0 \leq n \leq 10^5 )).

outputFormat

Output a single line with all prime numbers less than or equal to ( n ) separated by a single space. If there are no prime numbers, output an empty line.## sample

0