nicer imperative solution for problem 5 in racket
This commit is contained in:
parent
eae9b67bac
commit
fd219eee90
1 changed files with 2 additions and 10 deletions
12
5/euler5.rkt
12
5/euler5.rkt
|
@ -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))
|
|
Reference in a new issue