Changes between Initial Version and Version 1 of Ticket #876
- Timestamp:
- 06/26/12 13:58:15 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #876 – Description
initial v1 2 2 3 3 {{{ 4 (define (inc x) (+ x 1))5 6 4 (define (product-rec f a next b) 7 5 (if (> a b) 1 8 6 (* (f a) (product-rec f (next a) next b)))) 9 10 (define (fact n)11 (product-rec identity 1 inc n))12 7 13 8 (define (estimate-pi n) … … 16 11 (define (denom-term k) 17 12 (+ k (if (even? k) 1 2))) 18 (* 4 (product-rec (lambda (k) (/ (num-term k) (denom-term k))) 1 inc n))) 19 20 (define (product-iter f a next b) 21 (let loop ((accum 1) (x a)) 22 (if (> x b) accum 23 (loop (* accum (f x)) (next x))))) 13 (* 4 (product-rec (lambda (k) (/ (num-term k) (denom-term k))) 1 add1 n))) 24 14 25 15 (print (estimate-pi 100000)) 16 26 17 }}} 27 18