class Program
{
static void Main(string[] args)
{
int sum = 0, i, r;
Console.WriteLine("Enter the number");
int n = int.Parse(Console.ReadLine());
for (i = n; i > 0; i = i / 10)
{
r = i % 10;
sum = sum + r * r * r;
}
if (n == sum)
{
Console.WriteLine("This is Armstrong number");
}
else
{
Console.WriteLine("This is not Armstrong number");
}
Console.WriteLine();
Console.ReadLine();
}
}
OUTPUT:
Enter the number: 153
This is Armstrong number
No comments:
Post a Comment