While this procedure works correctly, it is not terribly efficient either in terms of time or required memory within the machine. Thus, the machine will need to store 1 until the recursive step is completely done.
Similar comments apply at each stage.
The next solution adds a running sum parameter. In this case, the machine does not need to combine the result at one stage with values at a previous stage, so earlier values need not be stored during recursion. This direct return of a result following recursion is called tail recursion . The following diagram provides a graphical picture of this processing. Since Scheme is sophisticated enough to identify when tail recursion is present, tail recursion can run particularly efficiently within Scheme.