previous | index | next

Logarithmic Recursion

Tree recursion is inefficient when subproblems are identical.

Use let to store intermediate results.

(define power
  (lambda (b e)
    (if (= e 0)
        1
        (if (even? e)
            _____________________
            (* b (power b (- e 1)))))))

previous | index | next