#K43597. Prime Numbers in a Range
Prime Numbers in a Range
Prime Numbers in a Range
Given two integers \(A\) and \(B\) where \(1 \le A \le B \le 10^6\), your task is to find all prime numbers in the inclusive range \([A, B]\). If there are no primes in the range, output No primes
. Use the Sieve of Eratosthenes method for an efficient solution.
inputFormat
The input consists of two space-separated integers A
and B
provided via standard input (stdin).
outputFormat
Output all prime numbers in the range \([A, B]\) separated by a single space to standard output (stdout). If no prime exists in the range, output No primes
. In case the range is invalid (i.e. if \(A > B\), \(A 10^6\)), output Invalid range
.
10 30
11 13 17 19 23 29