Miki1337

Untitled

Jan 19th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 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 Strong_number
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string number = Console.ReadLine();
  14. int factoriel = 1;
  15. int result = 0;
  16.  
  17. for (int i = 0; i < number.Length; i++)
  18. {
  19. int singleDigit = int.Parse(number[i].ToString());
  20. for (int j = 1; j <= singleDigit; j++)
  21. {
  22. factoriel *= j;
  23. }
  24. result += factoriel;
  25. factoriel = 1;
  26. }
  27.  
  28. if (result==int.Parse(number))
  29. {
  30. Console.WriteLine("yes");
  31. }
  32. else
  33. {
  34. Console.WriteLine("no");
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment