diff options
author | rsiddharth <s@ricketyspace.net> | 2017-05-27 21:08:00 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2017-05-27 21:08:00 +0000 |
commit | 246359ab7964855b02d7994588d8df10541ab599 (patch) | |
tree | 6842210a4151f946434a7a8a9f1bedf548265c2b | |
parent | 07407cff91928cf06b15c3150fb9166abb188cbb (diff) |
sicp.org: Add notes (2 -> 6 -> The Fermat Test).
-rw-r--r-- | sicp.org | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -8,6 +8,64 @@ begin with simplified, incomplete models. As we examine things in greater detail, these simple models become inadequate and must be replaced by more refined models. #+END_QUOTE +*** 2 +**** 6 +***** The Fermat Test + +#+BEGIN_EXAMPLE +(expmod 2 5 5) +(remainder (* 2 (expmod 2 4 5)) 5) +(remainder (* 2 (remainder (square (expmod 2 2 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder (square (expmod 2 1 5)) + 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder + (square (remainder + (* 2 (expmod + 2 + 0 + 5)) + 5)) 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder + (square (remainder + (* 2 1) 5)) + 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder (square (remainder 2 5)) + 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder (square 2) 5)) 5)) 5) +(remainder (* 2 (remainder (square (remainder 4 5)) 5)) 5) +(remainder (* 2 (remainder (square 4) 5)) 5) +(remainder (* 2 (remainder 16 5)) 5) +(remainder (* 2 1) 5) +(remainder 2 5) +2 +#+END_EXAMPLE + +#+BEGIN_EXAMPLE +(expmod 2 6 6) +(remainder (square (expmod 2 3 6) 6)) +(remainder (square (remainder (* 2 (expmod 2 2 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder (square (expmod 2 1 6)) + 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder + (square (remainder + (* 2 (expmod 2 0 6)) + 6)) 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder + (square (remainder (* 2 1) 6)) + 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder (square (remainder 2 6)) + 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder (square (remainder 2 6)) + 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder (square 2) 6)) 6)) 6) +(remainder (square (remainder (* 2 (remainder 4 6)) 6)) 6) +(remainder (square (remainder (* 2 4) 6)) 6) +(remainder (square (remainder 8 6)) 6) +(remainder (square 2) 6) +(remainder 4 6) +4 +#+END_EXAMPLE + ** guile *** use module #+BEGIN_SRC scheme |