|
|
| Keep It Simple, Stupid | |
| PerlMonks |
Re: Stirling Approx to N! for large Number?by tall_man (Parson) |
| on Mar 25, 2005 at 10:46 UTC ( [id://442358]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
There was a more accurate formula than Stirling's in tilly's post. Wolfram's Mathematica attributes it to Gosper:
This gives better accuracy for small numbers. For 8!, I get 40034.48, compared to the correct 40320. There are several problems with your implemenation of Stirling's formula. For one thing, log(e^(-n)), which you give as -e*log(n). Since the log is just the exponent base e, the correct answer is -n. Tilly's formula is closer to being right; there was only one parenthesis mistake. I corrected that and tried them all in a modified version of your code: I get the answers below:
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||