Any large factorial will have a number of zero behind it, and one could write an expression to compute the number of trailing zeros, but how would one go about computing the non-zero end digits?
E.g. compute first 5 non-zero end digits of (10^12)!
Any large factorial will have a number of zero behind it, and one could write an expression to compute the number of trailing zeros, but how would one go about computing the non-zero end digits?
E.g. compute first 5 non-zero end digits of (10^12)!
Hint: if you wanted just the last digit, a naive approach would be to do all the multiplication mod 10, skipping the 0's. $ (1*2*3*4*5*6*7*8*9)^{10^{11}}$. A second thought is that the $5$ swallows the $2$, so we can skip those. This works fine for all the factors besides $2$ and $5$, which need some more thought...
I solved this just now--a crucial fact is that there are more factors of 2 than of 5.
To formalize notation, let $v(N) $ be the largest positive integer such that $\large 10^{v(N))} | N$, and let $M(N) := \dfrac{N}{10^{v(N)}}$ denote the number of which we are trying to find the last 5 digits if $N = (10^{12})!$.
Hint: What can you say about $M(N) \mod 2^5$? How about $M(N) \mod 5^5$? How about $$ \Large M \left ( \prod_{\substack{ 1 \leq n \leq 10^{12} \\ 5 \not \, \,| \, n } } n \right ) \mod 5^5?$$ How about $$ \Large M \left ( \prod_{\substack{ 1 \leq n \leq 10^{12} \\ 25 \not \, \,| \, n } } n \right ) \mod 5^5?$$ Can you see a pattern?