Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement