class armstrong
{ public static void main(String args[])
{ int n , n1, rem , sum;
n = Integer.parseInt(args[0]);
n1 = n;
for(sum = 0 ; n > 0 ; n = n/10)
{ rem = n %10;
sum = sum + (rem*rem*rem);
}
if(n1 == sum)
System.out.println(n1 + " is Armstrong");
else
System.out.println(n1 + " is not Armstrong");
}
}
No comments:
Post a Comment