How to find maximum $x$ that $k^x$ divides $n!$ Given numbers $k$ and $n$
how can I find the maximum $x$ where:
$n! \equiv\ 0 \pmod{k^x}$?
I tried to compute $n!$
and then make binary search over some range $[0,1000]$ for example 
compute $k^{500}$
if $n!$ mod $k^{500}$ is greater than $0$ then I compute $k^{250}$ and so on
but I have to compute every time value $n!$ (storing it in bigint and everytime manipulate with it is a little ridiculous)
And time to compute $n!$ is $O(n)$, so very bad.
Is there any faster, math solution to this problem? Math friends?:)
Cheers Chris

Computing $n!$ it is a very bad idea for great numbers $n$. To find the desired exponent you should develop something similar to the Legendre formula.
You could also search for Legendre in the following document.
