PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Factorial Zeros
The factorial of a non-negative integer n, denoted by n! is the product of all positive integers less than or equal to n. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120.
Write a program to calculate the number of trailing zeros in n! where n is any positive number less than 10^7.
For Example:
Input: 5
Output: 1 (5! = 120 has one trailing zero)
Input: 10
Output: 2 (10! = 3628800 has two trailing zeroes)
"""
from math import factorial
nmbr=int(input())
fact =factorial(nmbr)
res=0
for x in range(1,(nmbr+1)):
if x%5==0:
res+=1
print ("{}! = {} has {} trailing zeroes".format(nmbr, fact, res))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run