Stirling's factorial approximation

db4
Alexander Solovyov 2008-02-13 00:24:32 +02:00
parent d88ed20a47
commit 01a811496f
1 changed files with 9 additions and 0 deletions

View File

@ -108,3 +108,12 @@ PRIVATE>
swap -1.0 * exp
*
] if ;
! James Stirling's approximation for N!:
! http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Numerical/Stirling/
: stirling-fact ( n -- fact )
[ pi 2 * * sqrt ]
[ dup e / swap ^ ]
[ 12 * recip 1 + ]
tri * * ;