(define (accumulate combiner null-value term a next b)
  (define (iter pos acc)
    (if (> pos b)
        acc
        (iter (next pos) (combiner acc (term pos)))))
  (iter a null-value))
(define (product factor a next b)
  (accumulate * 1 factor a next b))
(define (sum term a next b)
  (accumulate + 0 term a next b))