-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayprime.java
More file actions
51 lines (43 loc) · 808 Bytes
/
Copy patharrayprime.java
File metadata and controls
51 lines (43 loc) · 808 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package javatest;
import java.util.Scanner;
public class arrayprime {
public static void main(String[] args) {
int s,e;
System.out.println("enter the start range");
Scanner abc=new Scanner(System.in);
s=abc.nextInt();
System.out.println("enetr the end range");
e=abc.nextInt();
int [] a=new int[e-s];
String [] y=new String[e-s];
int d=0;
int g=0;
for(int i=s;i<e;i++) {
int c=0;
for(int j=2;j*j<=i;j++) {
if(i%j==0) {
c=c+1;
}
}
if(c==0) {
g++;
}
}
int [] p=new int[g];
for(int i=s;i<e;i++) {
int c=0;
for(int j=2;j*j<=i;j++) {
if(i%j==0) {
c=c+1;
}
}
if(c==0) {
a[d]=i;
d++;
}
}
for(int i=0;i<d;i++) {
System.out.println(a[i]);
}
}
}