-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_16.java
More file actions
43 lines (39 loc) · 732 Bytes
/
array_16.java
File metadata and controls
43 lines (39 loc) · 732 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
//WAP to find 38th prime and twist number.
public class array_16{
public static void main(String args[]){
int start=0, end=9, count=0,sum=0,count2=0,count3=0;
int n=1,n1=n;
while(true){
n1=n;
count=0;
count2=0;
sum=0;
for(int i=2; i<=n/2; i++){
if(n%i == 0){
count2++;
}
}
if(count2 == 0){
System.out.println(n1);
while(n1!=0){
sum *= 10;
sum += n1%10;
n1/=10;
}
for(int j=2; j<=sum/2; j++){
if(sum%j == 0){
count++;
}
}
if(count == 0){
count3++;
}
}
if(count3 == end){
System.out.println(n+ " is " +end+ "th prime and twist number.");
break;
}
n++;
}
}
}