Program:
import java.util.Scanner;
class arm_1000_22{
public static void main(String arg[]){
int i;
int num;
for(i=1;i<=1000;i++)
{
int sum=0;
int onum=num=i;
while(num!=0)
{
int rem=num%10;
sum=sum+rem*rem*rem;
num=num/10;
}
if(sum==onum)
System.out.println("your armstrong number is:"+sum);
}
}
}
public static void main(String arg[]){
int i;
int num;
for(i=1;i<=1000;i++)
{
int sum=0;
int onum=num=i;
while(num!=0)
{
int rem=num%10;
sum=sum+rem*rem*rem;
num=num/10;
}
if(sum==onum)
System.out.println("your armstrong number is:"+sum);
}
}
}
No comments:
Post a Comment