Advertisement
Spocoman

06. Strong number

Jan 12th, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StrongNumber
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string strNum = Console.ReadLine();
  10.             int number = int.Parse(strNum);
  11.             int sum = 0;
  12.  
  13.             for (int i = 1; i <= strNum.Length; i++)
  14.             {
  15.                 int factorial = 1;
  16.                 for (int j = 1; j <= number % 10; j++)
  17.                 {
  18.                     factorial *= j;
  19.                 }
  20.                 sum += factorial;
  21.                 number /= 10;
  22.             }
  23.  
  24.             Console.WriteLine(int.Parse(strNum) == sum ? "yes" : "no");
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement