SDE Path

Sieve of Eratosthenes

Medium

Sieve of Eratosthenes

Generate all prime numbers up to N using the sieve of Eratosthenes.

Input format

The first line contains N (2 ≤ N ≤ 300, distinct).

Output format

Print all primes ≤ N in ascending order.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
10
Expected output
2 3 5 7
Example 2
Input
2
Expected output
2