SHARE
TWEET

Untitled

a guest Oct 9th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace _01ExerciseStrongNumber
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int number = int.Parse(Console.ReadLine());
  10.             int copy = number;
  11.  
  12.             int currentNumber = 0;
  13.             int factSum = 0;
  14.  
  15.             while (copy != 0)
  16.             {
  17.                 currentNumber = copy % 10;
  18.                 copy = copy / 10;
  19.  
  20.                 int fact = 1;
  21.  
  22.                 for (int i = 1; i <= currentNumber; i++)
  23.                 {
  24.                     fact = fact * i;
  25.                 }
  26.                 factSum = factSum + fact;
  27.             }
  28.             if (number == factSum)
  29.             {
  30.                 Console.WriteLine("yes");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("no");
  35.             }
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top