image-20201116234841599

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;

public class Main {
public static void main(String[] args) {


Scanner input = new Scanner(System.in);
while (true) {
System.out.print("请输入N,M (例:2 16):");
int num = input.nextInt();
int num2 = input.nextInt();
int count = 0;
if (num < 100000 && num2 < 100000) {
for (int i = num; i <= num2; i++) {

if (i>=4 && i%2 != 0 ){

for (int m = 2; m<i;m++){
if (i%m==0) {
count++;
break;
}
}
}

}
System.out.println(count);
break;
} else {
System.out.println("请输入2个整数N,M(N,M<100000)!!!");
}
}
}
}