using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, sum = 0;
num = Convert.ToInt32(Console.ReadLine());
for (int i = num; i > 0;)
{
sum += (i % 10) * (i % 10) * (i % 10);
i = i / 10;
}
if(sum==num)
{
Console.WriteLine("No is armstrong");
}
else
{
Console.WriteLine("No is not armstrong ");
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num, sum = 0;
num = Convert.ToInt32(Console.ReadLine());
for (int i = num; i > 0;)
{
sum += (i % 10) * (i % 10) * (i % 10);
i = i / 10;
}
if(sum==num)
{
Console.WriteLine("No is armstrong");
}
else
{
Console.WriteLine("No is not armstrong ");
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment