In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given an integer n, we need to count the number of trailing zeros in the factorial.
Now let’s observe the solution in the implementation below −
Example
# trailing zero def find(n): # Initialize count count = 0 # update Count i = 5 while (n / i>= 1): count += int(n / i) i *= 5 return int(count) # Driver program n = 79 print("Count of trailing 0s "+"in",n,"! is", find(n))
Output
Count of trailing 0s in 79 ! is 18
Conclusion
In this article, we have learned about how we can make a Python Program to Count trailing zeroes in factorial of a number