(define (fast-expt b e)
  (define (even? n)
    (= (remainder n 2) 0))
  (define (square n)
    (* n n))
  (define (fast-expt-iter iter base result)
    (cond ((= iter 0) result)
	  ((even? iter) (fast-expt-iter (/ iter 2) (square base) result))
	  (else (fast-expt-iter (- iter 1) base (* result base)))))
  (fast-expt-iter e b 1))

(define (fast-expt b e)
  (define (even? n)
    (= (remainder n 2) 0))
  (define (square n)
    (* n n))
  (define (fast-expt-iter iter base result)
    (cond ((= iter 0) result)
	  ((even? iter) (fast-expt-iter (/ iter 2) (square base) result))
	  (else (fast-expt-iter (- iter 1) base (* result base)))))
  (fast-expt-iter e b 1))
