Note: I have asked this on mathoverflow.net here and have not been getting any answers so I have cross-posted.

From the comment on the other site, Gene Kopp points out that one can efficiently compute the lower order bits by doing modular arithmetic and higher order bits using Stirling's approximation, so this question is really 'how efficiently can one compute the middle order bits?'.

2 Answers
2

Dick Lipton has a beautiful post from 2009 on the relationship between the factorial function and factoring. There's a lot there that is unrelated to this question, but one salient point is this theorem:

If $n!$ can be computed by a
straight-line arithmetic computation
in $O(\log^{c} n)$ steps, then
factoring has polynomial size
circuits.

I suspect that this is evidence that your question, especially within the time bounds you mention, is going to be difficult to answer.

$\begingroup$Thank you, this is exactly the type of answer I was looking for. This doesn't directly answer my question and I don't see exactly how to connect the two, but it's close enough to put my mind at rest.$\endgroup$
– user834Oct 15 '10 at 14:59

Suresh's answer probably answers the question for you, but I thought I would point out a special case. You can always work out the result for the less significant digits for any base. Take $p$ as our base.

Clearly, every pth term in the factorial is a multiple of $p$. Every $(p^2)$th term is a multiple of $p^2$, etc. Thus the highest power of $p$ that is a factor of $N!$ is $X_p = \sum_{i=1}^{\lfloor \log_p(N!) \rfloor} \lfloor \frac{N}{p^i}\rfloor$. $\log_p(N!)$ is easy to approximate by Stirlings approximation: $\ln N! \approx N \ln N - N$. Further, $p^{N \lceil \log_p (N) \rceil} > N!$, so the sum can always be computed efficiently by summing instead for $1 \leq i \leq {N \lceil \log_p (N) \rceil}$ (since $\lfloor \frac{N}{p^i}\rfloor = 0$ for $i > {\lfloor \log_p(N!) \rfloor}$).