(define (fast-expt b n)
(cond ((= n 0) 1)
((even? n) (square (fast-expt b (/ n 2))))
(else (* b (fast-expt b (- n 1))))))
(define (even? n)
(= (remainder n 2) 0))
(fast-expt 3 3)
SICP 1.2.4 求幂
最新推荐文章于 2018-11-13 10:59:34 发布