#C3687. Prime Number Generator

    ID: 47141 Type: Default 1000ms 256MiB

Prime Number Generator

Prime Number Generator

Given an integer (N), your task is to generate all the prime numbers from 1 to (N) (inclusive). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. You are required to use an efficient algorithm (such as the Sieve of Eratosthenes) to compute the prime numbers.

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

inputFormat

Input is read from standard input (stdin). It consists of a single line containing an integer (N) (where (0 \leq N \leq 10^5)).

outputFormat

Output should be written to standard output (stdout) as a single line containing all prime numbers from 1 to (N) separated by a single space. If there are no primes (i.e. when (N < 2)), output an empty line.## sample

10
2 3 5 7