Consider that \begin{align} \Gamma(n+1) = n! \end{align} for any integers. I then got the following two questions:
- What is the largest value of $n$ for which $Γ(n+1)$ and $n!$ can be exactly represented by a double-precision floating-point number?
- What is the largest value of $n$ for which $Γ(n+1)$ and $n!$ can be approximately represented by a double-precision floating-point number that does not overflow?
So I have been working on this question for some time now but I do not seem to be satisfied by my own answer. My thoughts so far on (1.) is that since we start getting non representable integers after $2^{53}$ my initial guess would be the largest $n$ such that $n!=\Gamma(n+1)<2^{53}$. I found this value to be $n=18$ through MatLab simulations, I do wonder though if there are still some precisely represented for $n>18$, and how would I go about testing that?
I have run $\Gamma(n+1) - n!$ for several $n>18$ and they start getting some serious errors but only after $n=22$. It makes intuitive sense to me that the gamma function should produce more errors as it is a an approximation of an integral, but how am I to know that $23!$ is not also represented?
I also considered finding zeros for $$0=n! - (1+f)\cdot2^e$$ w.r.t $f$, note that $(1+f)$ is the mantissa and $2^e$ is the radix, such that the second term is in fact the positive normalized representation of the double float. My thought is that it would only be able to find a zero in case $f$ was a representable as a double float, however, I figured that this could not be done like this as $n!$ would always be either true or a rounding to a double float, so in any case MatLab would always be able to find a representable $f$ that produced a zero.
I am not sure how to continue with this exercise, any good pointers?