Armstrong Number
A number equal to the sum of the cubes of its digits is called an Armstrong number.
For example,
0, 1, 153, 370, 371 and 407.
Explanation:
153 = (1*1*1) + (5*5*5) + (3*3*3) = 1 + 125 + 27 = 153
Example:
using System; public class Example { public static void Main(string[] args) { int num, x, sum=0, y; Console.Write("Enter a Number: "); num = int.Parse(Console.ReadLine()); y = num; while(num>0) { x = num%10; sum = sum + (x*x*x); num = num/10; } if(y==sum) Console.Write("Armstrong Number!!"); else Console.Write("Not an Armstrong Number!!"); } } |
Output:
Explanation:
In the above example, we are displaying the C# program to check an Armstrong Number.