using System;
namespace Console_Armstrong
{
class Armstrong
{
int num,n=0,r,sum=0;
public void dispArm()
{
Console.WriteLine("Enter number :");
num = int.Parse(Console.ReadLine());
n = num;
while (n > 0)
{
r = n % 10;
n = n / 10;
sum += r * r * r;
}
if (sum == num)
{
Console.WriteLine("{0} is a amrstrong",num);
}
else
{
Console.WriteLine("{0} is numt a armstrong", num);
}
}
static void Main(string[] args)
{
Armstrong arm = new Armstrong();
arm.dispArm();
Console.ReadKey();
}
//output: 0,1,153,370,371,407
}
}
No comments:
Post a Comment