Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace armstrong
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter The Number");
- int num = int.Parse(Console.ReadLine());
- bool check= IsArmStrong(num);
- if (check)
- {
- Console.WriteLine("This Is An ArmStrong Number");
- }
- else Console.WriteLine("LOL NO!");
- }
- public static bool IsArmStrong(int n)
- {
- int orinal = n;
- int sum = 0;
- while(n>0)
- {
- sum += cube(n % 10);
- n = n / 10;
- }
- if (sum == orinal)
- {
- return true;
- }
- else return false;
- }
- public static int cube(int X)
- {
- return X * X * X;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement