First decimal digits of factorial $n$ divided by $x$

431 Views Asked by At

Actually, I will reformulate the question: how can I find a formula to calculate the nth decimal digit (the non-integer part) of f(x,n) = n!/x ? My idea is a Taylor serie of some kind but I don't know where to start. Any idea?

Formulated this way, the size of n and x is not relevant since I am looking for a formula.

This was the original question:

Consider we got a really big integer number, $n!$ where $n$ is at least $10$ digits long. I would like to calculate the $10$ first decimal digits of $\frac {n!}{x}$. Is there a practical way of doing this?

2

There are 2 best solutions below

3
On

Considering only $n!$, this makes a huge difference. What are the "first digits"? Are they from the left (the way we read a number in English) or from the right (the way usually done in Math)? If they are from the right like the units, ten, hundreds digits then the answer is easy for a large n factorial. As long as n is bigger than $44$, the first ten digits on the right will be all zeros. If you want the first ten nonzero digits from the right, Its highly nontrivial but I know for a fact it can be done but I don't remember the details of the method right now. You need some tricks with number theory and a bit of programming.

Since you say the decimal part of $\frac{n!}{x}$ you probably want the digits to right of the decimal point in $\frac {n!}{x}$. It would also depend on the size of $x$. How small or big is it? And at first thought its also looks like it would depend if $x$ is rational or irrational. If you do $\frac{100!}{2}$, the decimal part is zero because $2$ is a factor of the numerator. If you do $\frac {100!}{\frac13}$ well then the decimal part is zero again. And if you try $\frac {100!}{\frac23}$ then this is also a whole number with the decimal part being zero.

1
On

First, you want to find $n! \pmod x$. Then you can just use long division to get all the places you want. Depending on your computer, direct computation works fine up to $n \approx 10^8$ or so. You never need to handle a number bigger than $nx$.