Sieve of Eratosthenes - MarisaOJ: Marisa Online Judge

Sieve of Eratosthenes

Time limit: 1000 ms
Memory limit: 256 MB
Given an integer $n$. Find all primes that smaller or equal to $n$. ### Input - The first line contains an integer $n$. ### Output - Print all primes that smaller or equal to $n$ in ascending order. ### Constraints - $1 \le n \le 2 \times 10^6$. ### Example Input: ``` 15 ``` Output: ``` 2 3 5 7 11 13 ```