#C11603. Primes Up To N

    ID: 40938 Type: Default 1000ms 256MiB

Primes Up To N

Primes Up To N

Given a positive integer (N), your task is to compute all prime numbers less than or equal to (N). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Use the (O(N \log \log N)) Sieve of Eratosthenes algorithm to efficiently generate the primes. The output should print the prime numbers in ascending order separated by a space. If there are no primes, output an empty string.

inputFormat

The input consists of a single integer (N) ((0 \leq N \leq 10^6)) from standard input.

outputFormat

Output all prime numbers less than or equal to (N) in ascending order on one line, separated by a single space. If (N) is less than 2, output an empty line.## sample

10
2 3 5 7