127. Primes up to N
EasySieve
Print all primes ≤ n in increasing order, space-separated, or -1 if there are none.
Input format
A single integer n.
Output format
The primes, or -1.
Example 1
Input
10
Output
2 3 5 7
Example 2
Input
1
Output
-1
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…