Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. namespace TestGround
  5. {
  6. class Test
  7. {
  8. public static void Main(string[] args)
  9. {
  10. int number = int.Parse(Console.ReadLine());
  11. CalculateFactoriel(number);
  12. }
  13.  
  14. private static void CalculateFactoriel(int number)
  15. {
  16. BigInteger result = number;
  17. for (int i = 1; i < number; i++)
  18. {
  19. result = result * i;
  20. }
  21. CauntZeroesInResult(result);
  22. }
  23.  
  24. private static void CauntZeroesInResult(BigInteger result)
  25. {
  26. string resultStr = result.ToString();
  27. int countZeros = 0;
  28. int stringlenght = resultStr.Length;
  29. for (int i = 0; i < stringlenght; i++)
  30. {
  31. if (resultStr.EndsWith("0"))
  32. {
  33. countZeros++;
  34. resultStr = resultStr.Remove(resultStr.Length - 1);
  35. }
  36. else
  37. {
  38. Console.WriteLine(countZeros);
  39. return;
  40. }
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement