[ prog / sol / mona ]

prog


Help on the Way

82 2022-06-25 04:39

I am trying to solve SICP Exercise 1.16. Here is my solution:

(define (fast-expt-iter b n)
  (cond ((= n 1) b)
        ((even? n) (fast-expt-iter (square b) (/ n 2)))
        (else (fast-expt-iter (square b) (- n 1)))))

I can't find any error when I work it out on paper myself; but when I run it I get the wrong answer.
What am I missing here?

103


VIP:

do not edit these