Calculating the number of zeroes at the end of a factorial
This challenge looks familiar - I think I answered a similar challenge on our sister site, Programming Puzzles and Code Golf.  Those answers may not be as readable, though.

There's a couple of pieces of good news:


You don't need to count 2's in the prime factorization.  There will always be more 2's than 5's, so you can never have an unpaired 5.
You don't need to iterate over every number up to num if you see that we're just computing n/5 + n/25 + n/125 + ... (integer division).  If we define f(n) = n/5 + f(n/5) and f(0) = 0, we have a much faster version.  That can be implemented recursively, or fairly easily converted to iterative form.