FIND ARMSTRONG NUMBER USING COMMAND LINE ARGUMENT – JAVA

//PROGRAM TO FIND ARMSTRONG NUMBER USING COMMAND LINE ARGUMENT.
class ArmstrongCLA
{
public static void main(String a[])
{
int n=Integer.valueOf(a[0]);
int i=n,r,sum=0;

while(i>0)
{
r=i%10;
sum+=r*r*r;
i=i/10;
}
if(n==sum)
System.out.println(“the number is Armstrong”);
else
System.out.println(“the number is not Armstrong”);
}
}

Leave a Reply

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