Changes between Initial Version and Version 1 of Ticket #876


Ignore:
Timestamp:
06/26/12 13:58:15 (10 years ago)
Author:
Christian Kellermann
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #876 – Description

    initial v1  
    22
    33{{{
    4 (define (inc x) (+ x 1))
    5 
    64(define (product-rec f a next b)
    75  (if (> a b) 1
    86      (* (f a) (product-rec f (next a) next b))))
    9 
    10 (define (fact n)
    11   (product-rec identity 1 inc n))
    127
    138(define (estimate-pi n)
     
    1611  (define (denom-term k)
    1712    (+ 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)))
    2414
    2515(print (estimate-pi 100000))
     16
    2617}}}
    2718