#56Medium
Primes up to n
Time: 1 s · Memory: 256 MB
- Nested loops
Statement
You are given a natural number . Print all prime numbers from to . A prime is a number greater than that is divisible only by and by itself.
Input format
A single integer ().
Output format
A single line with the primes in increasing order, separated by spaces.
Examples
Input
10
Output
2 3 5 7
Input
13
Output
2 3 5 7 11 13
Note
The outer loop goes over the numbers from to , the inner loop searches for divisors. It is enough to check divisors up to , not up to : if is a divisor, so is . Write the condition as .
