The sieve of Eratosthenes is a famous algorithm to find all prime numbers up to
- Write down all integers between
and , inclusive. - Find the smallest number not already crossed out and call it
; is prime. - Cross out
and all its multiples that aren't already crossed out. - If not all numbers have been crossed out, go to step
.
Write a program that, given
Input Specification
The integers
Output Specification
Output the
Sample Input 1
Copy
7 3
Sample Output 1
Copy
6
Sample Input 2
Copy
15 12
Sample Output 2
Copy
7
Sample Input 3
Copy
10 7
Sample Output 3
Copy
9
In the third example, we cross out, in order, the numbers
Comments