Calculating large factorials without a calculator
My calculator cannot calculate anything over 69!, so how would I calculate
$\frac{80!}{60! \cdot 20! }$
without having to calculate
$\frac{80\cdot79\cdot78...61}{20\cdot19\cdot18...2}$
which would take a very long time to input?
$\endgroup$ 43 Answers
$\begingroup$Stirling's formula gives $$\log n!\approx n\log n - n + 1/2\log n + \log\sqrt{2\pi}$$ so $\log\frac{80!}{60!20!}\approx (80\log80-80+1/2\log80 + \log\sqrt{2\pi})-(60\log60-60+1/2\log60 + \log\sqrt{2\pi})-(20\log20-20+1/2\log20 + \log\sqrt{2\pi})=80.5\log80-60.5\log60-20.5\log20 - \log\sqrt{2\pi}$
which your calculator can calculate as $42.70933440$, so $$\frac{80!}{60!20!}\approx e^{42.70933440}=10^{42.70933440/\log 10}=10^{18.54842825}$$ $$=3.5353161\times10^{18}$$ compare with the precise result $$3.535316142212174320\times 10^{18}$$ we get the most significant $7$ digits right.
$\endgroup$ $\begingroup$I agree with JMoravitz's comment that $\binom{80}{20}$ is probably acceptable and that if you absolutely need an actual number, a program is the right way to go. However, if you multiply all those numbers together, you will likely have overflow: the numbers will be too big to store in a 64 bit integer. However, if the numbers given here are accurate, the final value itself appears to be small enough to fit into a 64 bit integer. There is another method to calculate this answer using 64 bit integers.
I assume you have heard of Pascal's Triangle?
$\endgroup$ $\begingroup$you could just cancel a lot of the terms away 80=16*5;78=2*3*13;76=4*19;74=2*37 the 37 isn't able to be cancelled. etc. reduce it to a form you can compute easy if need be.
$\endgroup$ 1