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
Latest commit
22 lines (21 loc) · 697 Bytes
/
Copy pathArmstrong.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
importjava.util.Scanner;
publicclassArmstrongNum {
staticintnumber, originalNumber, remainder, result = 0;
publicstaticvoidmain(String[] args) {
Scanners=newScanner(System.in);
ArmstrongNumnum = newArmstrongNum();
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.");
}
}