Is there a predefined procedure in Scheme that tests whether one integer is a multiple of another?
Only in the special case of 2: The even? predicate tests whether its
argument is a multiple of 2. But it's easy to write such a predicate:
(define (multiple? m n)
(if (zero? n)
(zero? m)
(zero? (remainder m n))))
Can you test whether one integer is evenly divisible by another?
Except in the special case where n is 0 (nothing is divisible
by zero), it's the same predicate:
(define (divisible? m n)
(if (zero? n)
#f
(zero? (remainder m n))))
Next topic
Previous topic
Table of contents
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/scheme-web/divisibility.html