;##################################################################### ;## PROBLEM 1 ;##################################################################### (define (factorial n) (if (= n 0) 1 (* n (factorial (- n 1))))) ;##################################################################### ;## PROBLEM 2 ;##################################################################### ;; compound-month B r: returns balance after 1 month of compounding (define (compound-month B r) (* B (+ 1 (/ r 1200.0)))) ;; compound-months B r m: returns balance after m months of compounding (define (compound-months B r m) (if (= m 0) B (compound-months (compound-month B r) r (- m 1)))) ;; accrue B r y: returns balance after y years of monthly compounding (define (accrue B r y) (compound-months B r (* y 12))) ;##################################################################### ;## PROBLEM 3 ;##################################################################### (define (fib n) (if (< n 2) 1 (+ (fib (- n 1)) (fib (- n 2)))))