calculate factorial with decimals
parent
b85616fa61
commit
90b06c55cd
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue