You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which can be brought into a calculable form with a separate order of magnitude like so:
$$\begin{aligned}
n! &\approx \sqrt{2 \pi n} \cdot A(n) \cdot \left(\frac{n}{e}\right)^n \text{ | Stirling's Approximation (A(n) only contains negative powers of n, not in exponents)} \\\
&\approx \sqrt{2 \pi n} \cdot A(n) \cdot \left(\frac{n}{e}\right)^m \cdot 10^k \text{ | factoring out the 10 exponent (k)} \\\
&\approx \sqrt{2 \pi n} \cdot A(n) \cdot \left(\frac{n}{e}\right)^{m + \frac{ln(10)}{ln\left(\frac{n}{e}\right)} k} \text{ | factoring it back in (to calculate it)} \\\
\\\
n &= m + log_{\frac{n}{e}}(10) \cdot k \text{ | got out of exponents} \\\
n &\approx log_{\frac{n}{e}}(10) \cdot k \text{ | m should be small} \\\
k &= \left\lfloor n / log_{\frac{n}{e}}(10) \right\rfloor \text{ | calculate k which is an integer (floor because otherwise m < 0)} \\\
m &= n - log_{\frac{n}{e}}(10) \cdot k \text{ | calculate the exponent for the calculation}
\end{aligned}$$
Approximate Multifactorial
We can bring the continuation into a calculable form (the major part) like so:
$$\begin{aligned}
z!_k &= k^{\frac{z}{k}} \cdot \frac{z}{k}! \cdot T_k(z) \text{ | we already have implementations for z! and T\_k(z)} \\\
\\\
k^{\frac{z}{k}} &= k^m \cdot 10^n \\
10^{log_{10}(k) \cdot \frac{z}{k}} &= 10^{log_{10}(k) \cdot m} \cdot 10^n \text{ | log\_{10}} \\\
log_{10}(k) \cdot \frac{z}{k} &= log_{10}(k) \cdot m + n \text{ | n should be as large as possible} \\\
\\\
n &= \left\lfloor log_{10}(k) \cdot \frac{z}{k} \right\rfloor \\\
m \cdot log_{10}(k) &= log_{10}(k) \cdot \frac{z}{k} - n | \div log_{10}(k) \\\
m &= \frac{z}{k} - \frac{n}{log_{10}(k)}
\end{aligned}$$
Approximate Multitermial
Multitermials have a simple formula:
$$n?_k \approx \frac{n(n+k)}{2k}$$
Which can be brought into a calculable form with a separate order of magnitude like so:
$$\begin{aligned}
n?_k &\approx \frac{n(n+k)}{2k} \\\
\\\
m &= \left\lfloor log_{10}(n) \right\rfloor \\\
\\\
n?_k &\approx k \frac{l}{2k} 10^{2m} \\\
n?_k &\approx k 10^m \cdot l \frac{10^m}{2k} \\\
\\\
k 10^m &\approx n \\\
k &\approx \frac{n}{10^m} \\\
l &= \frac{n+k}{10^m} \\\
\end{aligned}$$
Approximate Subfactorial
A subfactorial is approximately proportional to the factorial:
A subfactorial is approximately proportional to the factorial, less than an order of magnitude (just e) apart.
The number of digits does not significantly differ.
Float Factorial
The analytical continuation of factorials is the gamma function, which we use through rug (gmp):
$$x! = \Gamma(x+1)$$
Float Multifactorial
There is an analytical continuation of any k-factorial here: