The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need some attention and technicians need to check their function periodically.  

The technicians faced a very interesting problem recently. Given a set of BTSes to visit, they needed to find the shortest path to visit all of the given points and return back to the central company building. Programmers have spent several months studying this problem but with no results. They were unable to find the solution fast enough. After a long time, one of the programmers found this problem in a conference article. Unfortunately, he found that the problem is so called "Traveling Salesman Problem" and it is very hard to solve. If we have $N$ BTSes to be visited, we can visit them in any order, giving us $N!$  possibilities to examine. The function expressing that number is called factorial and can be computed as a product:

$1.2.3.4....N$. The number is very high even for a relatively small $N$.

The programmers understood they had no chance to solve the problem. But because they have already received the research grant from the government, they needed to continue with their studies and produce at least some results. So they started to study behaviour of the factorial function.  

For example, they defined the function $Z$. For any positive integer $N$, $Z$($N$) is the number of zeros at the end of the decimal form of number $N!$. They noticed that this function never decreases. If we have two numbers $N_{1} < N_{2}$ then  $Z(N_{1}) ≤ Z(N_{2})$. It is because we can never "lose" any
trailing zero by multiplying by any positive number. We can only get new and new zeros. The function $Z$ is very interesting, so we need a computer program that can determine its value efficiently.

------  Input: ------
There is a single positive integer $T$ on the first line of input (equal to about $100000$). It stands for the number of numbers to follow. Then there are $T$ lines, each containing exactly one positive integer number $N$, $1 ≤ N ≤ 10^{9}$.

------  Output: ------
For every number $N$, output a single line containing the single non-negative integer $Z(N)$.

----- Sample Input 1 ------ 
6
3
60
100
1024
23456
8735373
----- Sample Output 1 ------ 
0
14
24
253
5861
2183837

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
import math

def zero(n):
	count = 0
	x = n
	while x // 5 > 0:
		count += x // 5
		x = x // 5
	return count
t = int(input())
for i in range(t):
	n = int(input())
	print(zero(n))


for _ in range(int(input())):
	c = 0
	n = int(input())
	while n > 0:
		c += n // 5
		n //= 5
	print(c)


for _ in range(int(input())):
	x = int(input())
	ans = 0
	for j in range(1, 25):
		k = int(x / 5 ** j)
		if k >= 0:
			ans += k
		else:
			break
	print(ans)


for _ in range(int(input())):
	int1 = int(input())
	c = 0
	i = 0
	while i >= 0:
		int1 = int1 // 5
		c += int1
		if int1 == 0:
			print(c)
			break


n = int(input())
for i in range(n):
	m = int(input())
	cnt = 0
	while m != 0:
		cnt += m // 5
		m //= 5
	print(cnt)


n = int(input())
for i in range(n):
	s = int(input())
	c = 0
	while s > 0:
		c = c + s // 5
		s = s // 5
	print(c)


for t in range(int(input())):
	a = 0
	n = int(input())
	while n != 0:
		a += n // 5
		n //= 5
	print(int(a))


t = int(input())
for i in range(t):
	n = int(input())
	zeroes = 0
	i = 5
	while i <= n:
		zeroes += n // i
		i *= 5
	print(zeroes)


for i in range(int(input())):
	n = int(input())
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	print(count)


for _ in range(int(input())):
	n = int(input())
	(k, t) = (0, 0)
	while pow(5, k + 1) <= n:
		k += 1
	for i in range(1, k + 1):
		t += n // pow(5, i)
	print(t)


t = int(input())
for t in range(t):
	a = int(input())
	c = 5
	ct = 0
	while c <= a:
		ct = ct + int(a / c)
		c = 5 * c
	print(ct)


T = int(input())
for _ in range(T):
	N = int(input())
	ans = 0
	while N > 0:
		ans += N // 5
		N //= 5
	print(ans)


T = int(input())
for i in range(T):
	N = int(input())
	count = 0
	if N >= 5:
		while N >= 5:
			N = N // 5
			count = count + N
		print(count)
	else:
		print(0)


for i in range(int(input())):
	c = 0
	N = int(input())
	while N:
		c += N // 5
		N = N // 5
	print(c)


def Z(num):
	ans = 0
	while int(num / 5) != 0:
		num = int(num / 5)
		ans += num
	return ans
t = int(input())
for _ in range(t):
	num = int(input())
	print(Z(num))


for t in range(int(input())):
	count = 0
	n = int(input())
	while n != 0:
		count += n // 5
		n //= 5
	print(int(count))


import sys

def count_trailing_zeros(n):
	count = 0
	i = 5
	while n >= i:
		count += n // i
		i *= 5
	return count
T = int(sys.stdin.readline())
for i in range(T):
	N = int(sys.stdin.readline())
	print(count_trailing_zeros(N))


tests = int(input())
for _ in range(tests):
	N = int(input())
	count = 0
	if N >= 5:
		while N >= 5:
			N = N // 5
			count = count + N
		print(count)
	else:
		print(0)


def trailing(n):
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	print(count)
for _ in range(int(input())):
	n = int(input())
	trailing(n)


def trail(n):
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	print(count)
for i in range(int(input())):
	m = int(input())
	trail(m)


t = int(input())

def fact(n):
	count = 0
	while n > 0:
		count += n // 5
		n = n // 5
	return count
for _ in range(t):
	n = int(input())
	ans = fact(n)
	print(ans)


for i in range(int(input())):
	n = int(input())
	res = 0
	while n != 0:
		res += n // 5
		n //= 5
	print(res)


for t in range(int(input())):
	num = int(input())
	c = 0
	while num:
		c += num // 5
		num = num // 5
	print(c)


test = int(input())
for _ in range(test):
	n = int(input())
	ans = 0
	while n > 0:
		ans += n // 5
		n //= 5
	print(ans)


for i in range(int(input())):
	n = int(input())
	d = 0
	while n > 0:
		d += n // 5
		n //= 5
	print(d)


t = int(input())
for i in range(t):
	n = int(input())
	temp = 0
	while n > 1:
		temp += n // 5
		n = n // 5
	print(temp)


for i in range(int(input())):
	inp = int(input())
	count = 0
	while inp > 0:
		count += inp // 5
		inp = inp // 5
	print(count)


def trail(n):
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	print(count)
t = int(input())
while t:
	n = int(input())
	trail(n)
	t -= 1


def zero(n):
	x = n // 5
	y = x
	while x > 0:
		x /= 5
		y += int(x)
	return y
t = int(input())
for i in range(t):
	n = int(input())
	print(zero(n))


def lead(n):
	count = 0
	while n > 0:
		count = count + n // 5
		n = n // 5
	print(count)
t = int(input())
while t:
	n = int(input())
	lead(n)
	t = t - 1


def TSP(n):
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	return count
for i in range(int(input())):
	n = int(input())
	print(TSP(n))


n = int(input())
for i in range(n):
	a = int(input())
	k = 5
	c = 0
	while k <= a:
		c += a // k
		k *= 5
	print(c)


t = int(input())
while t:
	a = int(input())
	count = 0
	i = 5
	while a / i >= 1:
		count += int(a / i)
		i *= 5
	print(count)
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	(b, x) = (1, 5)
	c = 0
	while b != 0:
		b = n // x
		c = c + b
		x = x * 5
	print(c)


t = int(input())
for i in range(t):
	x = int(input())
	a = x // 5
	b = a
	while b >= 5:
		b = b // 5
		a = a + b
	print(a)


def trailing(n):
	count = 0
	while n > 0:
		count = count + n // 5
		n = n // 5
	print(count)
T = int(input())
for i in range(T):
	n = int(input())
	trailing(n)


t = int(input())
for _ in range(t):
	n = int(input())
	result = 0
	x = 5
	while x <= n:
		result = result + n // x
		x = x * 5
	print(result)


T = int(input())
for i in range(T):
	N = int(input())
	b = 0
	while N > 0:
		b += N // 5
		N //= 5
	print(b)


def Z(n):
	count = 0
	while n > 0:
		count += n // 5
		n //= 5
	return count
t = int(input())
for i in range(t):
	n = int(input())
	ans = Z(n)
	print(ans)


a = int(input())
for i in range(a):
	b = int(input())
	c = 0
	while b > 0:
		c += b // 5
		b //= 5
	print(c)


try:
	t = int(input())
	for r in range(t):
		n = int(input())
		c = 0
		while n > 0:
			if n > 0:
				n = n // 5
				c += n
		print(c)
except:
	pass


for i in range(int(input())):
	a = int(input())
	res = 0
	while a > 0:
		res += a // 5
		a //= 5
	print(res)


import math
for i in range(int(input())):
	a = int(input())
	count = 0
	while a != 0:
		count += a // 5
		a //= 5
	print(count)


for j in range(int(input())):
	n = int(input())
	c = 0
	c = n // 5
	n = n // 5
	while n > 1:
		n = n // 5
		c = c + n
	print(c)


def zeroes(n):
	if n < 0:
		return -1
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count
t = int(input())
for _ in range(t):
	n = int(input())
	print(zeroes(n))