;;; sicp 1.16
#lang scheme
(define (square x) (* x x))
(define (even? n)
(= (remainder n 2) 0))
(define (fast-expt-iter b counter product)
(if (= counter 0)
product
(if (even? counter)
(fast-expt-iter b
(/ counter 2)
(* b product product))
(fast-expt-iter b
(- counter 1)
(* b product))
)
))
(define (fast-expt b n)
(fast-expt-iter b n 1))
(fast-expt 2 16)
이것도 들렸다 ㅠㅠ
댓글 없음:
댓글 쓰기