Armstrong number

import java.util.*;
import java.util.Scanner;
class Arm
{
public static void main(String args[])
{
int num,temp,sum,i=1,n=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number:");
num=sc.nextInt();
sum=0;
i=num;
while(num>0)
{
n=num%10;
num=num/10;
sum=sum+(n*n*n);
}
if(sum==i)
{
System.out.print(i+"is an Armstrong number");
}
else
{
System.out.print(i+"is not an Armstrong number");
}
}
}
OUTPUT:
Enter the number:
153
153 is not an Armstrong number
Translate »