blob: 3fe26b5900f864093579b3cdabe1aa32a78dcd67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
(use-modules (srfi srfi-1))
(define (divisible? m n)
(zero? (modulo m n)))
(define (divisible-by-all? min max x)
(define (inner x n)
(cond ((= n max)
#t)
((divisible? x n)
(inner x (1+ n)))
(else
#f)))
(inner x min))
(define (smallest-multiple min max)
(define (inner n)
(if (divisible-by-all? min max n)
n
(inner (1+ n))))
(inner 1))
;; WARNING: Takes a long time.
(smallest-multiple 1 21)
|