- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayprime.java
More file actions
Latest commit
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
packagejavatest;
importjava.util.Scanner;
publicclassarrayprime {
publicstaticvoidmain(String[] args) {
ints,e;
System.out.println("enter the start range");
Scannerabc=newScanner(System.in);
s=abc.nextInt();
System.out.println("enetr the end range");
e=abc.nextInt();
int [] a=newint[e-s];
String [] y=newString[e-s];
intd=0;
intg=0;
for(inti=s;i<e;i++) {
intc=0;
for(intj=2;j*j<=i;j++) {
if(i%j==0) {
c=c+1;
}
}
if(c==0) {
g++;
}
}
int [] p=newint[g];
for(inti=s;i<e;i++) {
intc=0;
for(intj=2;j*j<=i;j++) {
if(i%j==0) {
c=c+1;
}
}
if(c==0) {
a[d]=i;
d++;
}
}
for(inti=0;i<d;i++) {
System.out.println(a[i]);
}
}
}