]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/e-decimals/e-decimals.factor
factor: Move math.ranges => ranges.
[factor.git] / extra / benchmark / e-decimals / e-decimals.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: decimals kernel locals math math.combinatorics ranges
4 sequences ;
5 IN: benchmark.e-decimals
6
7 : D-factorial ( n -- D! )
8     <iota> DECIMAL: 1 [ 0 <decimal> DECIMAL: 1 D+ D* ] reduce ; inline
9
10 :: calculate-e-decimals ( n -- e )
11     n [1..b] DECIMAL: 1
12     [ D-factorial DECIMAL: 1 swap n D/ D+ ] reduce ;
13
14 : e-decimals-benchmark ( -- )
15     5 [ 800 calculate-e-decimals drop ] times ;
16
17 MAIN: e-decimals-benchmark