Code Review

Compare your solutions

    #| Для этого упражнения нет проверок.
Любое решение будет считаться успешным ответом. |#
(define (smallest-divisor n)
  (find-divisor n 2))

(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))

(smallest-divisor 199)
;; > 199
;; this number is prime

(smallest-divisor 1999)
;; > 1999
;; this number is prime

(smallest-divisor 19999)
;; > 7
;; this number is not prime
;; 19999 = 7*2857