Factorials with an even number of trailing zeroes
Time limit1sMemory limit128 MB
Count how many k from 0 to n have a factorial ending in an even number of zeros for each query.
- Level
Medium7 of 10
- Topics
- Number theory, Dynamic programming, Math
- Solved
- No attempts yet
Problem
The factorial of a positive integer is written and is defined like this.
The value of is taken to be . As grows, grows very quickly. Here are a few values.
For some the number of trailing zeroes of is odd. That happens for and . For other it is even, as with , and .
Given , count how many of have an even number of trailing zeroes.
Input
Standard input holds one query per line, at most of them. Each query is a single integer ().
The last line holds . That line is not a query, it only marks the end of the input.
Output
Print one line per query. The line holds how many of have an even number of trailing zeroes.
Print nothing for the that ends the input.