(define mod-expt
(lambda (base exponent modulus)
(define mod*
(lambda (x y)
(remainder (* x y) modulus)))
(if (= exponent 0)
1
(mod* (mod-expt base (- exponent 1) modulus)
base))))
Recall: We want to compute
(be-1 mod m)b mod m.