- fibonacci nprocedure
Computes the nth Fibonacci number.
This naïve algorithm runs in O(2^n); using e.g. memoization, we could bring it down to O(n).
- n
- The nth number to calculate
(define (fibonacci n) (case n ((0) 0) ((1) 1) (else (+ (fibonacci (- n 1)) (fibonacci (- n 2))))))