2009-09-24 23:11:23 -04:00
|
|
|
! Copyright (C) 2009 Doug Coleman.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
|
USING: decimals kernel locals math math.combinatorics math.ranges
|
|
|
|
|
sequences ;
|
|
|
|
|
IN: benchmark.e-decimals
|
|
|
|
|
|
2009-09-25 00:41:34 -04:00
|
|
|
: D-factorial ( n -- D! )
|
2017-06-01 17:59:35 -04:00
|
|
|
<iota> DECIMAL: 1 [ 0 <decimal> DECIMAL: 1 D+ D* ] reduce ; inline
|
2009-09-25 00:41:34 -04:00
|
|
|
|
2009-09-24 23:11:23 -04:00
|
|
|
:: calculate-e-decimals ( n -- e )
|
2015-08-14 18:04:53 -04:00
|
|
|
n [1,b] DECIMAL: 1
|
|
|
|
|
[ D-factorial DECIMAL: 1 swap n D/ D+ ] reduce ;
|
2009-09-24 23:11:23 -04:00
|
|
|
|
2012-07-19 20:35:47 -04:00
|
|
|
: e-decimals-benchmark ( -- )
|
2009-09-24 23:11:23 -04:00
|
|
|
5 [ 800 calculate-e-decimals drop ] times ;
|
|
|
|
|
|
2012-07-19 20:35:47 -04:00
|
|
|
MAIN: e-decimals-benchmark
|