#C463. Trailing Zeros in Factorial
Trailing Zeros in Factorial
Trailing Zeros in Factorial
Given a non-negative integer n, compute the number of trailing zeros in n! (n factorial). The trailing zeros are produced by the factors of 10 in the factorial, and since 10 = 2 × 5 and there are typically more factors of 2 than 5, the problem reduces to counting the number of times 5 is a factor in n!.
More formally, the number of trailing zeros is given by the formula:
$$Z(n)=\left\lfloor\frac{n}{5}\right\rfloor+\left\lfloor\frac{n}{5^2}\right\rfloor+\left\lfloor\frac{n}{5^3}\right\rfloor+\cdots$$
Implement a program that reads an integer from standard input and outputs the number of trailing zeros in n!.
inputFormat
The input consists of a single non-negative integer n
provided via standard input.
Constraints: 0 \leq n \leq 10^9
(or as constrained by your programming language's integer limits).
outputFormat
Output a single integer which is the number of trailing zeros in n!.
## sample0
0