Now we test (if (<= n 0) ...) and call (factorial 1):
n = 1 |
n = 2 |
n = 3 |
and then we call (factorial 0):
n = 0 |
n = 1 |
n = 2 |
n = 3 |
This time, our test (if (<= n 0) ...) is true and we return the value 1 as the value of (factorial 0):
n = 1 |
n = 2 |
n = 3 |
Now the top stack frame has been popped off. We multiply 1 by the value of (factorial 0) (also 1) and return 1 as the value of (factorial 1).
Contents    Page-10    Prev    Next    Page+10    Index