A number that is equal to the sum of cube of its
digits
Example:
123=(1*1*1)+(2*2*2)+(3*3*3)
123 != 36 is not equal so it is not Armstrong
371=(3*3*3)+(7*7*7)+(1*1*1)
371==371 is equal, so it is Armstrong
import java.util.Scanner;
public class Armstrong {
public static void main(String[] arg){
Scanner sc=new Scanner(System.in);
System.out.println("Enter Number");
int i=sc.nextInt();
int j=i;
int a,b=0;
while(i>0){
a=i%10;
b=b+(a*a*a);
i=i/10;
}
if(b==j){
System.out.println(j+" is Armstrong number");
}
else{
System.out.println(j+" is not Armstrong number");
}
}
}
/*
Output1:
Enter Number
123
123 is not Armstrong number
Output2:
Enter Number
371
371 is Armstrong number
*/

