1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#lang racket (require "../../shared/chapter1.rkt") (require sicp) (define (factorial n) (product (lambda (x) x) 1 inc n)) (define (pi-product n) (/ (product (lambda (x) (if (even? x) x (+ x 1))) 2 inc n) (product (lambda (x) (if (even? x) (+ x 1) x)) 2 inc n))) (* 1.0 (pi-product 1000))