calculate factorial with decimals

db4
Doug Coleman 2009-09-24 23:41:34 -05:00
parent b85616fa61
commit 90b06c55cd
1 changed files with 5 additions and 2 deletions

View File

@ -4,9 +4,12 @@ USING: decimals kernel locals math math.combinatorics math.ranges
sequences ;
IN: benchmark.e-decimals
: D-factorial ( n -- D! )
D: 1 [ 0 <decimal> D: 1 D+ D* ] reduce ; inline
:: calculate-e-decimals ( n -- e )
n [1,b] [ factorial 0 <decimal> D: 1 swap n D/ ] map
D: 1 [ D+ ] reduce ;
n [1,b] D: 1
[ D-factorial D: 1 swap n D/ D+ ] reduce ;
: calculate-e-decimals-benchmark ( -- )
5 [ 800 calculate-e-decimals drop ] times ;