#C5432. Generate Prime Numbers
Generate Prime Numbers
Generate Prime Numbers
You are given a positive integer N. Your task is to generate all prime numbers up to and including N using an efficient algorithm such as the Sieve of Eratosthenes. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
The answer should be printed to standard output as a sequence of prime numbers separated by a single space. If there are no prime numbers (e.g., when N is less than 2), output nothing.
Note on Mathematical Formula: A number p is prime if and only if it is not divisible by any integer between 2 and \(\sqrt{p}\).
inputFormat
The input consists of a single integer N (\(0 \leq N \leq 10^5\)).
outputFormat
Output all prime numbers up to and including N in a single line, separated by a single space. If there are no primes, output an empty line.
## sample10
2 3 5 7
</p>