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! )
|
2010-01-14 13:08:22 -05:00
|
|
|
iota D: 1 [ 0 <decimal> D: 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 )
|
2009-09-25 00:41:34 -04:00
|
|
|
n [1,b] D: 1
|
|
|
|
|
[ D-factorial D: 1 swap n D/ D+ ] reduce ;
|
2009-09-24 23:11:23 -04:00
|
|
|
|
|
|
|
|
: calculate-e-decimals-benchmark ( -- )
|
|
|
|
|
5 [ 800 calculate-e-decimals drop ] times ;
|
|
|
|
|
|
|
|
|
|
MAIN: calculate-e-decimals-benchmark
|