Problem B
Reseto
The sieve of Eratosthenes is a famous algorithm to find all
prime numbers up to
-
Write down all integers between 2 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 2.
Write a program that, given
Input
The integers
Output
Output the
Sample Input 1 | Sample Output 1 |
---|---|
7 3 |
6 |
Sample Input 2 | Sample Output 2 |
---|---|
15 12 |
7 |
Sample Input 3 | Sample Output 3 |
---|---|
10 7 |
9 |