class ArmstrongDownload this program Here
{
public static void main(String[] args)
{
int n=143,temp,a=0,i=1;
temp=n;
while(i>0)
{
i=n%10;
a=(i*i*i)+a;
n=n/10;
}
if(a==temp)
System.out.println("the given number is armstrong");
else
System.out.println("the given number is not armstrong");
}
}
Output:
ReplyDeletethe given number is not Armstrong.
Armstrong means if the sum of cubes of each digit in a number is equals to the actual number.
for example 153