Iterative and recursive processes

A function f is defined by the rule that f(n) = n if n < 3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n ≥ 3. Write a procedure f that computes f by means of a recursive process. Write a procedure f-iter that computes f by means of an iterative process.


There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(check-equal? (f 5) 11)
(check-equal? (f-iter 5) 11)
(check-equal? (f 3) 3)
(check-equal? (f-iter 1) 1)