# SICP Solutions

### Chapter 5, Computing with Register Machines

#### Exercise 5.14

Code after making the changes in fact-machine as suggested in the problem:

Testing:

(make sure print is available while defining fact-machine)

Note that here total-pushes and maximum-depth are equal. This can be seen in the code too as we first iterate over all n and pushing values to stack without any pop operation. Once we reach bottom case then we perform pop and keep popping till stack becomes empty. Since every time we push two elements, it means that total-pushes should be in the multiples of 2.

Now, excluding the base case, where we do not push, it follows that formula should be $\, 2 \times (n - 1) \,$. This is indeed the case as can be seen from the output too.