Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370,371 and 407 are the Armstrong numbers. 153 = (1*1*1)+(5*5*5)+(3*3*3) = 1 + 125 + 27 = 153.
class Armstrong_no
{
public static void main(String args[])
{
int num,r,sum;
System.out.println("1 to 1000 Armstrong no");
for(int i=1;i<=1000;i++)
{
num=i;
sum=0;
while(num>0)
{
r=num%10;
sum=sum+r*r*r;
num=num/10;
}
if(sum==i)
System.out.print(i+"\t");
}
}
}
class Armstrong_no
{
public static void main(String args[])
{
int num,r,sum;
System.out.println("1 to 1000 Armstrong no");
for(int i=1;i<=1000;i++)
{
num=i;
sum=0;
while(num>0)
{
r=num%10;
sum=sum+r*r*r;
num=num/10;
}
if(sum==i)
System.out.print(i+"\t");
}
}
}