PROGRAM TO FIND NUMBER OF ARMSTRONG NUMBERS – JAVA

//PROGRAM TO FIND NUMBER OF ARMSTRONG NUMBERS
class NumArmstrong
{
public static void main(String a[])
{
int i,r,k;

for(k=2;k<=1000;k++)
{
int sum=0; i=k;
while(i>0)
{
r=i%10;
sum=sum+(r*r*r);
i=i/10;

}
if(k==sum)
System.out.println(k+” the number is Armstrong”);

}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *