Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 3b1179f

Browse files
shivaylambaHarshit1020
authored andcommitted
challenge 20
challenge 4 Signed-off-by: Harshit_Dongre <95414266+Harshit1020@users.noreply.github.com>
1 parent c95a857 commit 3b1179f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.Scanner;
2+
public class ArmstrongNum {
3+
public static void main(String[] args) {
4+
int n;
5+
Scanner sc = new Scanner(System.in);
6+
System.out.println("enter the value:");
7+
n = sc.nextInt();
8+
int temp = n;
9+
int rem, sum = 0;
10+
while(n > 0){
11+
12+
rem = n%10;
13+
sum = sum+(rem*rem*rem);
14+
n = n/10;
15+
}
16+
if(temp == sum){
17+
System.out.println("number is armstrong");
18+
}
19+
else{
20+
System.out.println("number is not armstrong");
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)