Homework 2, due 25 February 2008

Each problem is worth 10 points.

1. A function F is defined by the rule F(n) = n if n < 3 and F(n) = F(n-1)*F(n-2) - F(n-3)*F(n-3) otherwise. Write a procedure that computes F by means of a recursive process. Also write a procedure that computes F by means of an iterative process.

Hint: See how the Fibonacci sequence was computed by recursive and iterative processes.

2. Exercise 1.15, page 44.

3. Exercise 1.16, page 46. Hint: When your auxiliary function calls itself in its definition, what should the value of a be when n is odd? what should the base b be when n is even? In both cases, what should the new n be?