A number, as big as 1000! (! = factorial) is given. I need to find how many zeros are there in the number. I counted the no of terminal zeros by dividing 5, 25, 125, ... (untill fifth power < number). But thats just a part of it. I also need to count number of zeros in between the digits. For example 8! has a zero after 4 (40320). I need to count those to.
I spent hours still got nothing :P
Is it actually even possible? I am trying to write a program in C++ to count. I could divide the number by 100 and count zeros but 1000! is too huge even for a 64bit computer.
Any ideas, algorithms, formulae?