forked from Annex5061/java-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong.java
More file actions
22 lines (21 loc) · 697 Bytes
/
Armstrong.java
File metadata and controls
22 lines (21 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class ArmstrongNum {
static int number, originalNumber, remainder, result = 0;
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
ArmstrongNum num = new ArmstrongNum();
System.out.println("Enter the Number : ");
number = s.nextInt();
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.");
}
}