-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_17.java
More file actions
37 lines (35 loc) · 570 Bytes
/
array_17.java
File metadata and controls
37 lines (35 loc) · 570 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
//WAP to find 18th armstrong number.
//Output = 92727;
public class array_17{
public static void main(String args[]){
int end=18, start=0,count=0;
int n=1,n1=n, num=0, sum=0,count2=1;
while(true){
n1=n;
count=0;
num=0;
while(n1!=0){
n1/=10;
count++;
}
n1=n;
while(n1!=0){
count2=1;
sum = n1%10;
for(int i=1; i<=count; i++){
count2 *= sum;
}
n1/=10;
num += count2;
}
if(num == n){
start++;
}
if(start == end){
System.out.println(num);
break;
}
n++;
}
}
}