## Java Program:

- To check number is Armstrong or not

#### Example:

User Input:1

Output: Armstrong Number

``````import java.util.Scanner;
public class Armstrong {
public static void main(String []args) {
int num,num2,digit,sum=0;
Scanner userInput = new Scanner(System.in);
num = userInput.nextInt();
num2=num;
while(num!=0) {
digit=num%10;
sum= sum + digit*digit*digit;
num/=10;
}

if(num2==sum)System.out.println("Armstrong Number");
else System.out.println("Not a Armstrong Number");
}
}``````

### Output:

```  Enter Your number : 407
Armstrong Number
```
Program
number

You must know first,

Armstrong Number : if a number & cube of every single digit of the number are equal than the number is an Armstrong number

Example :

```Number: 407 & cube of every single digit = 407. so it's an Armstrong Number
(4*4*4)+(0*0*0)+(7*7*7) = 64+0+343 = 407```

``````//Save the original number
num2=num;

//find every single digit & add the cube of it
while(num!=0) {
digit=num%10;
sum=sum + digit*digit*digit;
num/=10;
}

//check for the Armstrong
if(num2==sum)
``````
Concept

Coming Soon !

Quick
Tutorial

# Quote

Be happy for this moment. This moment is your life.