-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_12.java
More file actions
31 lines (26 loc) · 493 Bytes
/
array_12.java
File metadata and controls
31 lines (26 loc) · 493 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
//WAP to find first 25 in reverse order
public class array_12{
public static void main(String args[]){
int n=1, count=0, end=0,count2=0;
int arr[] = new int[25];
while(true){
count2 = 0;
for(int i=1; i<=n; i++){
if(n%i == 0){
count2++;
}
}
if(count2 == 2){
arr[count++] = n;
end++;
}
if(end == 25){
break;
}
n++;
}
for(int j=arr.length-1; j>=0; j--){
System.out.print(arr[j]+" ");
}
}
}