for (int i = 100; i <= 999; i++)
{
int a = i / 100;
int b = (i - a * 100) / 10;
int c = (i - a * 100 - b * 10);
int d = a * a * a + b * b * b + c * c * c;
if (i == d)
System.Console.WriteLine("{0}", i);
}
Console.ReadKey();
Bu kod 100 ile 1000 arasındaki Armstrong sayılarını bulur.
153 = 1^3 + 5^3 + 3^3
370 = 3^3 + 7^3 + 0^3
371 = 3^3 + 7^3 + 1^3
407 = 4^3 + 0^3 + 7^3