#C13780. Find Prime Numbers in a Range

    ID: 43356 Type: Default 1000ms 256MiB

Find Prime Numbers in a Range

Find Prime Numbers in a Range

Given two integers (start) and (end) representing an inclusive range, your task is to find and output all prime numbers within that range. A prime number is a natural number greater than 1 that is divisible only by 1 and itself. Formally, a number (p) is prime if and only if (p > 1) and

$$\nexists\, d \in \mathbb{Z} \;\text{such that}\; 1 < d < p \;\text{and}\; p \mod d = 0. $$

If there are no prime numbers in the given range, output -1.

inputFormat

The input consists of a single line with two space-separated integers: (start) and (end), which define the inclusive range in which to find prime numbers.

outputFormat

Output all prime numbers in the inclusive range separated by a single space. If there is no prime number in the range, output -1.## sample

1 10
2 3 5 7