anizko

06. Strong number

May 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _6.Strong_Number
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N = int.Parse(Console.ReadLine());
  14.            
  15.             int Num = N;
  16.             int Total = 0;
  17.  
  18.             while (Num > 0)
  19.             {
  20.                 int Sum = 1;
  21.                 int Number = Num % 10;
  22.                 Num = Num / 10;
  23.  
  24.                 for(int i=Number;i>0;i--)
  25.                 {
  26.                     Sum *= i;
  27.                 }
  28.                 Total += Sum;
  29.                
  30.               }
  31.  
  32.             if (N == Total)
  33.             {
  34.                 Console.WriteLine("yes");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine("no");
  39.             }
  40.  
  41.  
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment