Chapter 1, Building Abstractions with Procedures
Section - Procedures and the Processes They Generate
Exercise 1.16
1
2
3
4
5
6
7
8
9
10
11
12
13
(define (fast-expt-itr b n)
(define (f-itr a x n)
(cond ((= n 0) a)
((even? n) (f-itr a (square x) (/ n 2)))
(else (f-itr (* a x) x (- n 1)))
)
)
(f-itr 1 b n)
)
(define (square x)
(* x x)
)