Problem:


階乗 II

n! = n &times; (n &minus; 1) &times; (n &minus; 2) &times; ...  &times; 3 &times; 2 &times; 1

を n の階乗といいます。例えば、12 の階乗は

12! = 12 &times; 11 &times; 10 &times; 9 &times; 8 &times; 7 &times; 6 &times; 5 &times; 4 &times; 3 &times; 2 &times; 1 = 479001600

となり、末尾に 0 が 2 つ連続して並んでいます。

整数 n を入力して、n! の末尾に連続して並んでいる 0 の数を出力するプログラムを作成してください。ただし、n は 20000 以下の正の整数とします。

Input

複数のデータが与えられます。各データに n (n ≤ 20000) が１行に与えられます。n が 0 の時入力の最後とします。

データの数は 20 を超えません。

Output

各データに対して n! の末尾に連続して並んでいる 0 の数を１行に出力して下さい。

Sample Input

2
12
10000
0

Output for the Sample Input

0
2
2499



Sample input:
2
12
10000
0


Sample output:
0
2
2499

Submission status: Accepted

Solution code:
import math
while True:
    zero_counter = 0
    num = int(input())
    if num == 0:
        break
    splited_num = list(str(math.factorial(num)))

    for i in reversed(splited_num):
        if i == "0":
            zero_counter += 1
        else:
            break

    print(zero_counter)

Submission status: Runtime Error

Solution code:
import math
while True:
	x = math.factorial(int(input()))
	n = list(str(x))
	con = 0
	for i in range(len(n)-1,0,-1):
		if n[i] != '0':
			break
		con += 1
	print(con)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python
import math

while True:
    inp = input()
    if inp == '0': break

    num = math.factorial(int(inp))
    cnt = 0
    while True:
        if num % 10 == 0:
            cnt = cnt + 1
            num = num / 10
        else:
            break

    print(cnt)

Submission status: Runtime Error

Solution code:
import math

while True:
    inp = input()
    if inp == '0': break

    num = math.factorial(int(inp))
    cnt = 0
    while True:
        if num % 10 == 0:
            cnt = cnt + 1
            num = num / 10
        else:
            break

    print(cnt)

Submission status: Runtime Error

Solution code:
def factorial(n):
    res = 1
    for i in range(1, n+1):
        res = res * i
    return res

while True:
    inp = input()
    if inp == '0': break

    num = factorial(int(inp))
    cnt = 0
    while True:
        if num % 10 == 0:
            cnt = cnt + 1
            num = int(num / 10)
        else:
            break

    print(cnt)

Submission status: Runtime Error

Solution code:
while True:
    inp = input()
    if inp == '0': break

    num = 1
    for i in range(1, int(inp)):
        num = num * i

    cnt = 0
    while True:
        if num % 10 == 0:
            cnt = cnt + 1
            num = int(num / 10)
        else:
            break

    print(cnt)

Submission status: Runtime Error

Solution code:
while 1:
    n,i=int(input()),0
    if n==0:break
    n=str(math.factorial(n))[::-1]
    while n[i]=='0':i+=1
    print(i)

Submission status: Runtime Error

Solution code:
for e in iter(input,'0'):
 e=int(e)
 print(sum(n//5**i)for i in range(1,6)))

Submission status: Runtime Error

Solution code:
for e in iter(input,'0'):
 e=int(e)
 print(sum(e//5**i)for i in range(1,6)))

Submission status: Runtime Error

Solution code:
for e in iter(input,'0'):
 e=int(e)
 print(sum(e//5**ifor i in range(1,6)))

Submission status: Runtime Error

Solution code:
import sys
for n in sys.stdin:
    c=0
    for i in range(1,int(n)+1):
        while i%5==0:
            i/=5
            c+=1
    print c

Submission status: Runtime Error

Solution code:
import sys
for n in sys.stdin:
    c=0
    for i in range(1,int(n)+1):
        j=i
        while j%5==0:
            j/=5
            c+=1
    print c