Advertisement
TeMePyT

Untitled

Jun 2nd, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System. Numerics;
  3.  
  4. namespace factorialTrailingZeroes
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11. BigInteger number = 0;
  12. BigInteger result = GetFactorial(n, number);
  13. BigInteger countZeroes = CountZeroes(result);
  14. Console.WriteLine(countZeroes);
  15. }
  16.  
  17. static BigInteger GetFactorial(int n, BigInteger number)
  18. {
  19. number = 1;
  20. for (int i = 1; i <= n; i++)
  21. {
  22. number *= i;
  23. }
  24. return number;
  25. }
  26.  
  27. static BigInteger CountZeroes(BigInteger result)
  28. {
  29. int count = 0;
  30. while (result % 10 == 0)
  31. {
  32. BigInteger num = result % 10;
  33. if (num % 10 == 0)
  34. count++;
  35. result /= 10;
  36. }
  37.  
  38. return count;
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement