Find Prime Numbers
InterviewTime limit2sMemory limit256 MB
Print all prime numbers between two given bounds M and N, one per line, using an efficient sieve up to 1,000,000.
- Level
Easy3 of 10
- Topics
- Math, Number theory, Sorting
- Solved
- No attempts yet
Problem
Given two natural numbers M and N, write a program that prints every prime number from M through N in increasing order.
Input
The first line contains the natural numbers M and N separated by a space.
- 1 ≤ M ≤ N ≤ 1,000,000
- The input always contains at least one prime number in the inclusive range [M, N].
Output
Print the prime numbers from M through N in increasing order, one per line.