Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (fast-expt b n)
- (define (even? a)
- (= (remainder a 2) 0))
- (define (check? a)
- (< (* a 2) n))
- (define (fast-expt-iter b count product)
- (cond ((< n count) product)
- ((and (even? count) (check? count)) (fast-expt-iter b (+ count count) (square product)))
- (else (fast-expt-iter b (+ count 1) (* b product)))))
- (fast-expt-iter b 1 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement