;; divisorsOf: natnum natnum ' list-of-natnum ;; Returns all the divisors of divisee less than or equal to maxDivisor ;; including 1 and divisee, if it is less than maxDivisor. (define (divisorsOf divisee maxDivisor) (local [;;divisorsOfdivisee: natnum --> list-of-natnum ;;Returns all the divisors of divisee less than or equal to divisor ;; including 1 and divisee, if it is less than divisor. ;;Note that divisee does not need to be passed because it is ;;in the closure of this function already. (define (divisorsOfdivisee divisor) (cond [(zero? divisor) empty] [(< 0 divisor) (cond [(= 0 (modulo divisee divisor)) (cons divisor (divisorsOfdivisee (sub1 divisor)))] [else (divisorsOfdivisee (sub1 divisor))]) ]))] (divisorsOfdivisee maxDivisor))) "divisorsOf test cases" (equal? empty (divisorsOf 5 0)) (equal? (list 3 2 1) (divisorsOf 0 3)) (equal? (list 10 5 2 1) (divisorsOf 10 10)) (equal? (list 2 1) (divisorsOf 10 4)) (equal? (list 12 6 4 3 2 1) (divisorsOf 12 48))