forked from ghostmkg/programming-language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong.java
More file actions
38 lines (34 loc) · 723 Bytes
/
Armstrong.java
File metadata and controls
38 lines (34 loc) · 723 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
import java.util.*;
class Armstrong
{
int arm(int n)
{
int c,s=0;
while(n>0)
{
c=n%10;
s=s+(int)(Math.pow(c,3));
n=n/10;
}
return s;
}
void range(int l,int u)
{
int i;
for(i=l;i<=u;i++)
{
if(i==arm(i))
System.out.println(i+" ");
}
}
public static void main()
{
Scanner sc=new Scanner(System.in);
Armstrong ob=new Armstrong();
int lo,up;
System.out.println("Enter the lower and the upper limits");
lo=sc.nextInt();
up=sc.nextInt();
ob.range(lo,up);
}
}