#K14816. Sieve of Eratosthenes: Prime Number Generation

    ID: 24219 Type: Default 1000ms 256MiB

Sieve of Eratosthenes: Prime Number Generation

Sieve of Eratosthenes: Prime Number Generation

In this problem, you are required to implement the Sieve of Eratosthenes algorithm to generate all prime numbers less than a given integer (n).

The Sieve of Eratosthenes is an efficient way to identify all prime numbers up to a certain limit (n). The algorithm works by iteratively marking the multiples of each prime starting from 2.

Your task is to read an integer (n) from standard input, and output all prime numbers strictly less than (n> in a single line, separated by spaces. If there are no prime numbers less than (n), output an empty line.

inputFormat

The input consists of a single integer (n) ((1 \leq n \leq 10^6)) provided via standard input.

outputFormat

Output all prime numbers less than (n) in one line separated by a single space. If no prime exists, print an empty line.## sample

10
2 3 5 7

</p>