Advertisement
Guest User

Untitled

a guest
Apr 4th, 2014
138
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.Numerics;
  3.  
  4. class Program
  5. {
  6. public static BigInteger CalculateCustomFactoriel(int x)
  7. {
  8. BigInteger result = 1;
  9. while (x > 0)
  10. {
  11. result *= x;
  12. x--;
  13. }
  14. return result;
  15. } // testing method
  16. static void Main()
  17. {
  18. int n = int.Parse(Console.ReadLine());
  19. int sumOfFives = 0;
  20. int powedFive = 1;
  21. int result;
  22. for (int i = 1; i < n; i++)
  23. {
  24. powedFive = (int)Math.Pow(5, i);
  25. result = n / powedFive;
  26. if (result > 1)
  27. {
  28. Console.WriteLine(result);
  29. sumOfFives += result;
  30. }
  31. else
  32. {
  33. break;
  34. }
  35. }
  36. Console.WriteLine(sumOfFives);
  37. Console.WriteLine(CalculateCustomFactoriel(n)); // for test
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement