//Using Java
class Arm{
public static void main(String args[])
{
int num=Integer.parseInt(args[0]);
int temp=num,rem;
double sum=0;
while(temp!=0)
{
rem=temp%10;
sum=sum+Math.pow(rem,3);
temp/=10;
}
if(sum==num)
System.out.println(num+" is an armstrong number.");
else
System.out.println(num+" is not an armstrong number.");
}
}
class Arm{
public static void main(String args[])
{
int num=Integer.parseInt(args[0]);
int temp=num,rem;
double sum=0;
while(temp!=0)
{
rem=temp%10;
sum=sum+Math.pow(rem,3);
temp/=10;
}
if(sum==num)
System.out.println(num+" is an armstrong number.");
else
System.out.println(num+" is not an armstrong number.");
}
}
No comments:
Post a Comment