# SICP Solutions

### Section - Formulating Abstractions with Higher-Order Procedures

#### Exercise 1.38

We need to generate denominators in the following way: 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1…

If we look closely, ignoring the first two terms of the series, then:

$(position - 2)\mod 3 = 0$ for all the terms which are not equal to $1$.

Similarly note that the values can also be derived for this position:

if $position > 2$ and its value is not equal to $1$, than it is: $2 \times (1 + (position-2)/3)$.

Now we can easily write the procedure for computing $e$ using cont-frac from previous exercise:

Note that we are also adding 2 as call to cont-frac returns $e - 2$.

Sample invocation using $k = 20$: