Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Factorial
- {
- class MainClass
- {
- static int fivePowerSum (int x)
- {
- return (int)((Math.Pow (5, x) - 1) / 4);
- }
- static int z (int x)
- {
- if (x < 5)
- return 0;
- int result = 0;
- int log;
- do {
- log = -1;
- int fivePower = 1;
- do {
- fivePower *= 5;
- log++;
- } while (x>=fivePower);
- int fivePowerDiv5 = fivePower / 5;
- result += (fivePowerDiv5 - 1) / 4;
- x -= fivePowerDiv5;
- } while (log>0);
- return result;
- }
- public static void Main (string[] args)
- {
- int testCases = Convert.ToInt32 (Console.ReadLine ());
- int[] xs = new int[testCases];
- for (int i=0; i<testCases; i++)
- xs [i] = Convert.ToInt32 (Console.ReadLine ());
- foreach (int x in xs)
- Console.WriteLine (z (x));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement