-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimeMain.java
More file actions
37 lines (29 loc) · 751 Bytes
/
Copy pathPrimeMain.java
File metadata and controls
37 lines (29 loc) · 751 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
35
36
37
//2081/12/15
// prime check of given range
// lab question
package lab2java;
import java.util.Scanner;
public class PrimeMain {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("enter starting range:");
int a=s.nextInt();
System.out.println("enter ending Range:");
int b=s.nextInt();
for(int i=a;i<b;i++)
{
int flag=1;
for(int j=2;j<=i/2;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
if(flag==1){
System.out.println(i);
}
}
}
}