Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int inputNum = int.Parse(Console.ReadLine());
  10.             long checkNum = inputNum;
  11.             long factorialSum = 0;
  12.  
  13.             while (checkNum != 0)
  14.             {
  15.                 long result = checkNum % 10;
  16.                 checkNum /= 10;
  17.  
  18.                 long factorial = 1;
  19.                 for (int i = 1; i <= result; i++)
  20.                 {
  21.                     factorial *= i;
  22.                 }
  23.                 factorialSum += factorial;
  24.             }
  25.  
  26.             if (factorialSum == inputNum)
  27.             {
  28.                 Console.WriteLine("yes");
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("no");
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement