using System;
class Program
{
static int armstrong(int n) {
int reminder = 0, sum = 0, total_digits = (int)Math.Log10(n) + 1;;
while (n > 0) {
reminder = n % 10;
sum += (int)Math.Pow(reminder, total_digits);
n = n / 10;
}
return sum;
}
static void Main() {
int n = 153; // 1*1*1 + 5*5*5 + 3*3*3 = 153
if (n == armstrong(n))
Console.WriteLine("Armstrong number");
else
Console.WriteLine("Not armstrong number");
n = 9474; // 9*9*9*9 + 4*4*4*4 + 7*7*7*7 + 4*4*4*4 = 9474
if (n == armstrong(n))
Console.WriteLine("Armstrong number");
else
Console.WriteLine("Not armstrong number");
}
}
/*
run:
Armstrong number
Armstrong number
*/