class ArmString
{
public static void main(String arg[])
{
int n;
n = Integer.parseInt(arg[0]);
int digit, sum, num;
sum = 0;
System.out.println();
num = n;
System.out.println("Number : " + n);
while (n > 0)
{
digit = n % 10;
sum = sum + (digit * digit * digit);
n = n / 10;
}
System.out.println();
System.out.println("Sum : " + sum);
if (sum == num)
{
System.out.println("Given number is an ArmStrong");
}
else
{
System.out.println();
System.out.println("Given number is not an ArmStrong");
}
}
}
No comments:
Post a Comment