x! = 1 · 2 · … · x, with 0! = 1. For instance, 10! = 3628800 ends in two zeros.
Given zeros, count how many non-negative integers x have x! ending in exactly zeros zeros in decimal.
For large zeros you cannot compute the factorials themselves, so look for the pattern.zeros=1 → 5
Exactly one trailing zero appears in 5!, 6!, 7!, 8! and 9! (5! = 120, while 10! already ends in 00). The answer is 5.
zeros=5 → 0
24! ends in 4 zeros and 25! jumps straight to 6, because the factor 25 adds two at once. Exactly five never happens, so the answer is 0.
zeros=0 → 5
zeros=1
5
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.