SICP 1.21
(define (smallest-divisor n) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-divisor) (else (find-divisor n (+ test-divisor 1))))) (define (divides? a b) (= (remainder b a) 0)) (define (square a) (* a a)) (define (remainder a b) (modulo a b)) (find-divisor n 2)) (smallest-divisor 199) (smallest-divisor 1999) (smallest-divisor 19999)