-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprg12.java
More file actions
35 lines (30 loc) · 673 Bytes
/
Copy pathprg12.java
File metadata and controls
35 lines (30 loc) · 673 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
class prg12{
static void checkArmstrong(int n1,int n2)
{
for(int j=n1+1;j<n2;j++){
int y=j;
int N=0;
while(y!=0)
{
y/=10;
N++;
}
y=j;
int sum=0;
while(y!=0)
{
int d=y%10;
sum+=Math.pow(d,N);
y/=10;
}
if (sum == j)
System.out.print(j + " ");
}
}
public static void main(String[] args) {
int n1=100;
int n2=900;
checkArmstrong(n1,n2);
System.out.println();
}
}