-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathProgram25.java
More file actions
34 lines (32 loc) · 794 Bytes
/
Copy pathProgram25.java
File metadata and controls
34 lines (32 loc) · 794 Bytes
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
import java.util.Scanner;
class Program25 {
public static void main(String args[]) {
try (Scanner input = new Scanner(System.in)) {
int m, n;
int count = 0;
int totalprime = 0;
System.out.print("Enter initial number:");
m = input.nextInt();
System.out.print("Enter last number: ");
n = input.nextInt();
for (int i = m; i <= n; i++) {
if (i < 2) {
continue;
} else {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
count++;
break;
}
}
if (count == 0) {
System.out.println(i);
totalprime++;
}
count = 0;
}
}
System.out.println("total prime:" + totalprime);
}
}
}