forked from dscmsit/Problem-Solving-in-any-Language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong.java
More file actions
24 lines (20 loc) · 703 Bytes
/
Armstrong.java
File metadata and controls
24 lines (20 loc) · 703 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
import java.util.Scanner;
public class Armstrong {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Count :");
int number =sc.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.");
}
}