-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrongNofun.java
More file actions
54 lines (41 loc) · 1.02 KB
/
ArmstrongNofun.java
File metadata and controls
54 lines (41 loc) · 1.02 KB
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
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
public class ArmstrongNofun
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int l=lenght(n);
//System.out.println(l);
int t1=n;
int r;
int arm=0;
while(t1!=0)
{
int mul=1;
r=t1%10;
for(int i=1;i<=l;i++)
{
mul=mul*r;
}
arm=arm+mul;
t1=t1/10;
}
System.out.println(arm);
if(arm==n)
{
System.out.println("Armstrong no");
}
else
System.out.println("not Armstrong");
}
static int lenght(int n1)
{
int t=n1;
int l=0;
while(t!=0){
t=t/10;
l=l+1;
}
return l;
}
}