read

recursive process

(define (f n)
  (if (< n 3)
      n
      (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3))))))

iterative process

(define (f-iter a0 a1 a2 n)
  (if (= n 0) a0
      (f-iter a1 a2 (+ (* 3 a0) (* 2 a1) a2) (- n 1))))
(define (f n)
  (f-iter 0 1 2 n))

Blog Logo

Ki Sung Bae


Published

Image

Gsong's Blog

Developer + Entrepreneur = Entreveloper

Back to Overview