import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int M = Integer.parseInt(bf.readLine());
int N = Integer.parseInt(bf.readLine());
int min = Integer.MAX_VALUE;
int sum = 0;
for(int i=M; i<=N; i++) {
boolean isPrime = true;
for(int j=2; j<i; j++) {
if(i%j == 0) {
isPrime = false;
break;
}
}
if(i !=1 && isPrime) {
min = Math.min(i, min);
sum += i;
}
}
if(sum==0) {
System.out.println(-1);
}else {
System.out.println(sum);
System.out.println(min);
}
}
}
소수.. 2부터.. 1은 X.
'알고리즘 > BOJ' 카테고리의 다른 글
BOJ 10866 (0) | 2022.08.05 |
---|---|
BOJ 10845 (0) | 2022.08.04 |
BOJ 10828 (0) | 2022.08.02 |
BOJ 9012 (0) | 2022.08.02 |
BOJ 1244 (0) | 2022.08.01 |