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
(define (divisible-by? num lst)
(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))
(do ((n 20 (+ n 20)))
((andmap zero? (map ((curry remainder) n) (range 1 21))) n))