sicp-solutions/ex-1.16.scm
Petar Kapriš a697f52405 Add solutions to exercises from section 1.2
To be noted: the drawing in exercise 1.14 is unfinished. I did it in a
notebook, but haven't yet had the time to put it in a txt file.
2025-02-05 13:59:25 +01:00

8 lines
200 B
Scheme

#lang sicp
(define (expt-aux b n a)
(cond ((= n 0) a)
((even? n) (expt-aux (* b b) (/ n 2) a))
(else (expt-aux b (- n 1) (* a b)))))
(define (solution b n)
(expt-aux b n 1))