#C14356. Counting Trailing Zeros in Factorials
Counting Trailing Zeros in Factorials
Counting Trailing Zeros in Factorials
Given a non-negative integer \( n \), your task is to compute the number of trailing zeros in \( n! \) (n factorial).
The number of trailing zeros in \( n! \) is determined by the number of times 10 divides \( n! \). Since 10 is the product of 2 and 5 and there are usually more factors of 2 than 5, the problem reduces to counting the number of times 5 is a factor in the numbers from 1 to \( n \). Mathematically, the number of trailing zeros is given by:
\[ T(n) = \sum_{i=1}^{\infty} \left\lfloor \frac{n}{5^i} \right\rfloor \]
Implement a function to compute \( T(n) \).
inputFormat
The input consists of a single non-negative integer \( n \) provided via standard input.
outputFormat
Output a single integer which is the number of trailing zeros in \( n! \), printed to standard output.
## sample0
0