#K78137. List All Primes
List All Primes
List All Primes
Given a non-negative integer \(n\), your task is to compute and print all prime numbers less than or equal to \(n\). A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. Use an efficient algorithm (for example, the Sieve of Eratosthenes) to generate all the primes in the range \([2, n]\).
Print the prime numbers in ascending order, separated by a single space. If \(n < 2\) so that there is no prime number, output an empty line.
inputFormat
The input consists of a single integer \(n\) (where \(0 \leq n \leq 10^6\)).
outputFormat
Output a single line containing all prime numbers less than or equal to \(n\) separated by a single space. If there are no primes, output an empty line.
## sample0