Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Factorial
- {
- class MainClass
- {
- static int z (int x)
- {
- int result = 0;
- int[] fivePowerModulo = new int[ (int)Math.Log (x, 5) + 1];
- for (int i=1; i<=x; i++) {
- int j = 0;
- Power:
- fivePowerModulo [j]++;
- if (fivePowerModulo [j] == 5) {
- fivePowerModulo [j] = 0;
- j++;
- goto Power;
- }
- result += j;
- }
- 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