Advertisement
dradoslavov89

Untitled

Sep 24th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _06.Strong_number
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13. int numPlus = 0;
  14. int factorial = 1;
  15.  
  16. int num1 = n % 10;
  17. n = n / 10;
  18. int num2 = n % 10;
  19. n = n / 10;
  20. int num3 = n % 10;
  21. n = n / 10;
  22. int num4 = n % 10;
  23. n = n / 10;
  24. int num5 = n % 10;
  25.  
  26.  
  27.  
  28. factorial = 1;
  29.  
  30. for (int i = 1; i <= num5; i++)
  31. {
  32.  
  33. factorial *= i;
  34. }
  35.  
  36. numPlus += factorial;
  37. factorial = 1;
  38.  
  39. for (int i = 1; i <= num4; i++)
  40. {
  41.  
  42. factorial *= i;
  43. }
  44. numPlus += factorial;
  45. factorial = 1;
  46.  
  47. for (int i = 1; i <= num3; i++)
  48. {
  49.  
  50. factorial *= i;
  51. }
  52. numPlus += factorial;
  53. factorial = 1;
  54.  
  55.  
  56. for (int i = 1; i <= num2; i++)
  57. {
  58.  
  59. factorial *= i;
  60. }
  61. numPlus += factorial;
  62. factorial = 1;
  63.  
  64. for (int i = 1; i <= num1; i++)
  65. {
  66.  
  67. factorial *= i;
  68. }
  69. numPlus += factorial;
  70. factorial = 1;
  71.  
  72. if (n==numPlus)
  73. {
  74. Console.WriteLine("yes");
  75. }
  76. else
  77. {
  78. Console.WriteLine("no");
  79. }
  80.  
  81. Console.WriteLine(numPlus);
  82.  
  83.  
  84.  
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement