

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Recursion is one of the most powerful ideas in Computer Science and in Mathematics. A proper understand- ing of it is essential. All the lectures from here on out will really be about recursion.
Write the factorial function.
Write the function inclist that returns an incremented version of the list given to it.
Mattox Beckman Page 1 Illinois Institute of Technology
Find the tail calls!
1 (define (calc n i) 2 (cond [(= n 2) i] 3 [(= (modulo n 2) 1) 4 (calc (+ 1 (* n 3)) (+ 1 i))] 5 [else (calc (/ n 2) (+ i 1))])) 6 7 (define (fib n) 8 (cond [(= n 0) 0] 9 [(= n 1) 1] 10 [else (+ (fib (- n 1)) (fib (- n 2)))]))
1 (define (fib n) 2 (cond [(= n 0) 0] 3 [(= n 1) 1] 4 [else (+ (fib (- n 1)) (fib (- n 2)))]))
Mattox Beckman Page 2 Illinois Institute of Technology