-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharmstrongNo.java
More file actions
45 lines (37 loc) · 896 Bytes
/
armstrongNo.java
File metadata and controls
45 lines (37 loc) · 896 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
44
45
import java.util.Scanner;
public class armstrongNo
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int t1=n;
int len=0;
while(t1!=0)
{
t1=t1/10;
len=len+1;
}
// System.out.println(len);
int t2=n;
int arm=0;
int r;
while(t2!=0)
{ int mul=1;
r=t2%10;
for(int i=1;i<=len;i++){
mul=mul*r;
}
//System.out.println(mul);
arm=arm+mul;
t2=t2/10;
}
//System.out.println(arm);
if(arm==n)
{
System.out.println("Armstrong no");
}
else
System.out.println("not a armstrong no");
}
}