]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex1_23.clj
Merge branch 'master' of github.com:vu3rdd/sicp
[sicp.git] / src / sicp / ex1_23.clj
1 (ns sicp.ex1_23
2   (:use [sicp utils]
3         [clojure.contrib trace test-is]))
4
5 ;;; exercise 1.23
6 (defn next-divisor [n]
7   (if (= n 2)
8     3
9     (+ n 2)))
10
11
12 (defn find-divisor [n test-divisor]
13   (cond (> (square test-divisor)  n) n
14         (divides? test-divisor n) test-divisor
15         :else (find-divisor n (next-divisor test-divisor))))
16
17 (comment
18   I can't see any noticable difference in the speed.
19 )