nicer imperative solution for problem 5 in racket

This commit is contained in:
Lowl3v3l 2017-06-13 16:57:18 +02:00
parent eae9b67bac
commit fd219eee90

View file

@ -1,12 +1,4 @@
#lang racket #lang racket
(do ((n 20 (+ n 20)))
(define (divisible-by? num lst) ((andmap zero? (map ((curry remainder) n) (range 1 21))) n))
(andmap (λ (x) (zero? (remainder num x))) lst))
(define (find-divisible-num it lst)
(if (divisible-by? it lst)
it
(find-divisible-num (+ 2 it) lst)))
(find-divisible-num 2 (range 1 21))