This commit is contained in:
NaiJi ✨ 2020-08-03 22:57:03 +03:00
parent 9e4576c291
commit 149e9dfd32
1 changed files with 19 additions and 0 deletions

19
sicp-ex-1.16 Normal file
View File

@ -0,0 +1,19 @@
; UNFINISHED
(define (sqr n)
(* n n))
(define (fast-ext-iter number power product)
(cond ((= power 0) product)
((even? power) (fast-ext-iter number
(/ power 2)
(if (= product 1)
(sqr number)
(sqr product))))
(else (fast-ext-iter number
(- power 1)
(* power product)))))
(define (fast-ext number power)
(fast-ext-iter number power 1))
(fast-ext 2 8)