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;
- namespace _06.Strong_number
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int numPlus = 0;
- int factorial = 1;
- int num1 = n % 10;
- n = n / 10;
- int num2 = n % 10;
- n = n / 10;
- int num3 = n % 10;
- n = n / 10;
- int num4 = n % 10;
- n = n / 10;
- int num5 = n % 10;
- factorial = 1;
- for (int i = 1; i <= num5; i++)
- {
- factorial *= i;
- }
- numPlus += factorial;
- factorial = 1;
- for (int i = 1; i <= num4; i++)
- {
- factorial *= i;
- }
- numPlus += factorial;
- factorial = 1;
- for (int i = 1; i <= num3; i++)
- {
- factorial *= i;
- }
- numPlus += factorial;
- factorial = 1;
- for (int i = 1; i <= num2; i++)
- {
- factorial *= i;
- }
- numPlus += factorial;
- factorial = 1;
- for (int i = 1; i <= num1; i++)
- {
- factorial *= i;
- }
- numPlus += factorial;
- factorial = 1;
- if (n==numPlus)
- {
- Console.WriteLine("yes");
- }
- else
- {
- Console.WriteLine("no");
- }
- Console.WriteLine(numPlus);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement