Primes in a range
Read two integers L and R and print all prime numbers between them (inclusive), separated by spaces. If there are none, print -1.
Reported in: LTIMindtree, Tech Mahindra (memory-based)
Input
One line: L and R.
Output
The primes, or -1.
Constraints
1 ≤ L ≤ R ≤ 10^6.
Example 1
Input:
10 30
Output:
11 13 17 19 23 29Example 2
Input:
24 28
Output:
-1Hint: Test divisibility only up to the square root of each number.