# Exercise 1.32

**a.** Recursive version of `accumulate`

:

```
(define (accumulate combiner null-value term a next b)
(if (> a b)
null-value
(combiner (term a)
(accumulate combiner null-value term (next a) next b))))
```

We show how we can rewrite the `sum`

and `product`

procedures using `accumulate`

:

```
(define (sum term a next b)
(accumulate + 0 term a next b))
(define (product term a next b)
(accumulate * 1 term a next b))
```

**b.** Iterative version of `accumulate`

: