-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArm.java
More file actions
43 lines (35 loc) · 722 Bytes
/
Arm.java
File metadata and controls
43 lines (35 loc) · 722 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
import java.util.Scanner;
class Arm{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n,count=0,sum=0,temp,num,newnum,newn,poww;
int mul;
System.out.println("Enter a number:");
n = sc.nextInt();
temp = n;
while(temp>0){
count++;
temp = temp / 10;
}
num = count;
newn = n;
while(count>0){
newnum = newn % 10;
poww = num;
mul = 1;
while(poww>0){
mul = mul * newnum;
poww--;
}
sum = sum + mul;
newn = newn/ 10;
count--;
}
if (n == sum){
System.out.println(n+" is Armstrong number...");
}
else{
System.out.println(n+" is non-Armstrong number...");
}
}
}