From fd219eee90d40bb5266a04348ac455484179b904 Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Tue, 13 Jun 2017 16:57:18 +0200 Subject: [PATCH] nicer imperative solution for problem 5 in racket --- 5/euler5.rkt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/5/euler5.rkt b/5/euler5.rkt index da02856..1b0dc32 100644 --- a/5/euler5.rkt +++ b/5/euler5.rkt @@ -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)) \ No newline at end of file +(do ((n 20 (+ n 20))) + ((andmap zero? (map ((curry remainder) n) (range 1 21))) n)) \ No newline at end of file