Double Factorial
Time limit1sMemory limit128 MB
Count the trailing zeros of the product of the first n factorials, where n can reach 10^18.
- Level
Medium7 of 10
- Topics
- Math, Binary search, Number theory
- Solved
- No attempts yet
Problem
For a positive integer , its factorial is the product of all integers from to . Define the double factorial of as the product of the first factorials:
Given , determine the number of trailing zeros in the decimal representation of this double factorial.
Input
A single line contains one integer ().
Output
Print a single line with the number of trailing zeros of the double factorial of .
Hint
For , the double factorial equals , which has trailing zeros.