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 _1._6_Strong_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int tempNum = num;
- int totalFactorialSum = 0;
- while (tempNum > 0)
- {
- int digit = tempNum % 10;
- tempNum /= 10;
- int currentFactorialSum = 1;
- for (int i = 1; i <= digit; i++)
- {
- currentFactorialSum *= i;
- }
- totalFactorialSum += currentFactorialSum;
- }
- if (num == totalFactorialSum)
- {
- Console.WriteLine("yes");
- }
- else
- {
- Console.WriteLine("no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment