forked from I-RoshanKumar/Beginner_Hactoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong.java
More file actions
25 lines (20 loc) · 683 Bytes
/
Armstrong.java
File metadata and controls
25 lines (20 loc) · 683 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
import java.util.*;
public class Armstrong {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
System.out.println("Enter the number ");
int number = scn.nextInt();
int originalNumber, remainder, result = 0;
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber % 10;
result += Math.pow(remainder, 3);
originalNumber /= 10;
}
if(result == number)
System.out.println(number + " is an Armstrong number.");
else
System.out.println(number + " is not an Armstrong number.");
}
}