2020-08-03 21:57:03 +02:00
|
|
|
(define (sqr n)
|
|
|
|
(* n n))
|
|
|
|
|
|
|
|
(define (fast-ext-iter number power product)
|
|
|
|
(cond ((= power 0) product)
|
2020-08-11 00:32:48 +02:00
|
|
|
((even? power) (fast-ext-iter (sqr number)
|
2020-08-03 21:57:03 +02:00
|
|
|
(/ power 2)
|
2020-08-11 00:32:48 +02:00
|
|
|
product))
|
2020-08-03 21:57:03 +02:00
|
|
|
(else (fast-ext-iter number
|
|
|
|
(- power 1)
|
2020-08-11 00:32:48 +02:00
|
|
|
(* number product)))))
|
2020-08-03 21:57:03 +02:00
|
|
|
|
|
|
|
(define (fast-ext number power)
|
|
|
|
(fast-ext-iter number power 1))
|
|
|
|
|
2020-08-11 00:32:48 +02:00
|
|
|
(fast-ext 2 5)
|