Travelling zero's



Problem to find the how many zero's contains last in factorial value.



Example-1:


Input    : n = 5
Output   : 1 
Explain  : 5!=120. Only one zero contain in last. 


Example-2:


Input    : n = 12
Output   : 2
Explain  : 12!=479001600.Two zero's contains in last. 


Example-3:


Input    : n = 15
Output   : 3
Explain  : 15!=1307674368000.Three zero's contains in last. 







Solution




n = 5

k = 1

count = 0

for i in range(1,n+1):

    k *= i

k = str(k)

k = k[::-1]

for j in range(len(k)):

    if(k[j] != "0"):

        break

    else:

        count += 1

print(count)



Output



1