SICP Exercise 1.25

Exercise 1.25.  Alyssa P. Hacker complains that we went to a lot of extra work in writing expmod. After all, she says, since we already know how to compute exponentials, we could have simply written


(define (expmod base exp m)
  (remainder (fast-expt base exp) m))


Is she correct? Would this procedure serve as well for our fast prime tester? Explain.

SOLUTION



Comments

Popular posts from this blog

SICP Exercise 2.56 differentiation rule

SICP Exercise 1.28 (Miller-Rabin Test)

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions