Exercise 4.4

The last version of mod-expt given in the text is logarithmic recursive:
(define mod-expt
  (lambda (base exponent modulus)
    (define mod*
      (lambda (x y)
        (remainder (* x y) modulus)))
    (if (= exponent 0)
        1
        (if (even? exponent)
            (let ((x (mod-expt base (/ exponent 2) modulus)))
              (mod* x x))
            (mod* (mod-expt base (- exponent 1) modulus)
                  base)))))
You need to make this logarithmic iterative, using the fact that when e is even:

be = (be/2)2 = (b2)e/2