Solve 1.16
This commit is contained in:
parent
d49f5893ae
commit
ca2a636675
|
@ -1,19 +1,16 @@
|
|||
; UNFINISHED
|
||||
(define (sqr n)
|
||||
(* n n))
|
||||
|
||||
(define (fast-ext-iter number power product)
|
||||
(cond ((= power 0) product)
|
||||
((even? power) (fast-ext-iter number
|
||||
((even? power) (fast-ext-iter (sqr number)
|
||||
(/ power 2)
|
||||
(if (= product 1)
|
||||
(sqr number)
|
||||
(sqr product))))
|
||||
product))
|
||||
(else (fast-ext-iter number
|
||||
(- power 1)
|
||||
(* power product)))))
|
||||
(* number product)))))
|
||||
|
||||
(define (fast-ext number power)
|
||||
(fast-ext-iter number power 1))
|
||||
|
||||
(fast-ext 2 8)
|
||||
(fast-ext 2 5)
|
Loading…
Reference in New Issue