(define factorial (lambda (n) (if (= n 0) 1 (* (factorial (- n 1)) n))))A trace of (factorial 5):
> (factorial 5) |(factorial 5) | (factorial 4) | |(factorial 3) | | (factorial 2) | | |(factorial 1) | | | (factorial 0) | | | 1 | | |1 | | 2 | |6 | 24 |120 120Because problems must wait for subproblems to be solved and then to resume, more memory is needed.