-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArm.java
More file actions
33 lines (32 loc) · 772 Bytes
/
Arm.java
File metadata and controls
33 lines (32 loc) · 772 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
import java.util.Scanner;
class Arm{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.err.println("enter the number");
int n=sc.nextInt();
int sum=0;
int d=0;
int t=n;
while(t>0){
t=t/10;
d++;
}
t=n;
while(t>0){
int digit=t%10;
t=t/10;
int power=1;
for (int i = 0; i < d; i++) {
power *=digit;
}
sum+=power;
}
if(sum==n){
System.err.println("the number is armstrong "+n);
}
else{
System.err.println("the number is not a armstrong "+n);
}
sc.close();
}
}