Advertisement
AnastasiyaG

Untitled

Jan 20th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string number = Console.ReadLine();
  10. int total = 0;
  11. int sum = 0;
  12.  
  13. for (int i = 0; i <= number.Length; i++)
  14. {
  15. char current = number[i];
  16.  
  17. int num = ((int)current);
  18.  
  19. for (int j = 1; j <=num; j++)
  20. {
  21. sum *= j;
  22.  
  23. }
  24. total += sum;
  25.  
  26. }
  27.  
  28.  
  29. int stringToNum = int.Parse(number);
  30. if (stringToNum == total)
  31. { Console.WriteLine("yes"); }
  32. else { Console.WriteLine("no"); }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement