SICP Exercise 1.27 (Carmichael Numbers)



Exercise 1.27.  Demonstrate that the Carmichael numbers listed in footnote 47 really do fool the Fermat test. That is, write a procedure that takes an integer n and tests whether an is congruent to a modulo n for every a<n, and try your procedure on the given Carmichael numbers.

SOLUTION

The code and tests are here.

Observations
============

The above program demonstrates that the Carmichael numbers 561, 1105....to 6601 fool the Fermat test. These are all composite numbers that pass the Fermat test.

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