(define power ; compute be iteratively (lambda (b e) (power-product 1 b e))) (define power-product (lambda (a b e) ; returns a times be (if (= e 0) a (power-product (* a b) b (- e 1)))))Linear iteration can be converted to logarithmic iteration by recognizing that if e is even, then
(define power-product (lambda (a b e) (if (= e 0) a (if (even? e) (power-product a (* b b) (/ e 2)) (power-product (* a b) b (- e 1))))))