What I am trying to figure out is a way to compute large factorials, !1000000
.
For what it's worth luschny's computer algorithms do a very good job of it.
What I am trying to figure out is a way to compute large factorials, !1000000
.
For what it's worth luschny's computer algorithms do a very good job of it.
Let's take an example which fits on the page, which you can extend if you want. As a product of powers of primorials, you have
$100!=p_{1}\#^{49}\times p_{2}\#^{24}\times p_{3}\#^{8}\times p_{4}\#^{7}\times p_{5}\#^{2}\times p_{6}\#^{2}\times p_{8}\#\times p_{9}\#\times p_{11}\#\times p_{15}\#\times p_{25}\#$
where for example $p_{3}\#^{8}$ means the eighth power of the third primorial, i.e. $(2 \times 3 \times 5)^8$.
The reason for an eighth power is that the prime factorisation of $100!$ includes $5^{24}$ and $7^{16}$ with $24-16=8$. One way of calculating this to to take $\left( \left\lfloor \frac{100}{5^1}\right\rfloor +\left\lfloor \frac{100}{5^2}\right\rfloor +\left\lfloor \frac{100}{5^3}\right\rfloor +\cdots \right) - \left( \left\lfloor \frac{100}{7^1}\right\rfloor +\left\lfloor \frac{100}{7^2}\right\rfloor +\left\lfloor \frac{100}{7^3}\right\rfloor +\cdots \right). $