2 days ago

my attempt to do the exercises in sicp.

## Sunday, September 6, 2009

### sicp exercise 3.9

; Exercise 3.9. In section 1.2.1 we used the substitution model to analyze two procedures for computing factorials, a recursive version

;

; (define (factorial n)

; (if (= n 1)

; 1

; (* n (factorial (- n 1)))))

;

; and an iterative version

;

; (define (factorial n)

; (fact-iter 1 1 n))

; (define (fact-iter product counter max-count)

; (if (> counter max-count)

; product

; (fact-iter (* counter product)

; (+ counter 1)

; max-count)))

;

; Show the environment structures created by evaluating (factorial 6) using each version of the factorial procedure.

Subscribe to:
Post Comments (Atom)

## 1 comment:

First of all congratulations for your work do you have the exercises in PDF version? could you send me the exercises to my mail? jorgekvron@gmail.com .a greeting and thanks

Post a Comment