### What is Armstrong number

An Armstrong number is a number where sum of the cube of its digit is equal to the original number.

• Example: 153, 370, 371, 407, etc. are Armstrong numbers.
• Sample Input: 153
• Logic statement:(1 X 1 X 1)=1
• (5 X 5 X 5)=125
• (3 X 3 X 3)=27
• Sum =(1 + 125 + 27)=153
• Sample output: 153 which is equal to the original number, that’s why 153 is a Armstrong number

Let’s see another example:

• Sample input: 407
• Logic statement: (4 X 4 X 4)=64
• (0 X 0 X 0)=0
• (7 X 7 X 7)=343
• Sum= (64 + 0 + 343)= 407
• Sample output: 407 which is equal to the original number, that’s why 407 is a Armstrong number
``````// program to check an inputted number is Armstrong or not
import java.util.Scanner;
class Armstrong
{
public static void main(String args[])
{
int num,org_num, rem,sum=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter any number");
num=sc.nextInt();
org_num=num;
while(num!=0)
{
rem=num%10;
sum=sum+(rem*rem*rem);
num=num/10;
}

if(sum==org_num)
System.out.println(org_num+" is a Armstrong number");
else
System.out.println(org_num+" is not a Armstrong

number");
}
}
``````

Output: