Hacker Earth Problems - Trailing Zeros


Problem Statement:
Given a number find the number of trailing zeroes in its factorial.
Input Format
A single integer – N
Output Format
Print a single integer which is the number of trailing zeroes.
Input Constraints
1 <= N <= 1000
Problem Setter: Practo Tech Team

Sample Input
10
Sample Output
2
Explanation
10! = 3628800 has 2 zeros in the end.

Solution:
Language : Python
from math import *
import re
num = input()
k = (str(factorial(num)))[::-1]
#print k
l = len(k)
i = 0
count=0
while(k[i]==’0′):
count+=1
i+=1
print count

Comments

Popular Posts