using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArmstrongNumber
{
class Program
{
static void Main(string[] args)
{int n,m,s=0,r;
Console.WriteLine("Enter a Number");
n=Convert.ToInt16(Console.ReadLine());
m = n;
while (n > 0)
{
r = n % 10;
s = s + r * r * r;
n = n / 10;
}
if (m == s)
Console.WriteLine("Armstrong Number");
else
Console.WriteLine("Not an Armstrong Number");
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArmstrongNumber
{
class Program
{
static void Main(string[] args)
{int n,m,s=0,r;
Console.WriteLine("Enter a Number");
n=Convert.ToInt16(Console.ReadLine());
m = n;
while (n > 0)
{
r = n % 10;
s = s + r * r * r;
n = n / 10;
}
if (m == s)
Console.WriteLine("Armstrong Number");
else
Console.WriteLine("Not an Armstrong Number");
Console.ReadKey();
}
}
}
0 comments:
Post a Comment