What does the gcd procedure do?
It computes and returns the largest integer that evenly divides all of its
operands. (But if it is not given any operands, or if all of its operands
are zero, the gcd procedure returns 0.)
Do all the operands have to be integers?> (gcd 165 70) 5 > (gcd -165 -70) 5 > (gcd 1000 1001) 1 > (gcd 12 18 30) 6 > (gcd 360) 360 > (gcd 0 12) 12 > (gcd 60 84 140 210) 2 > (gcd 0 0 0) 0 > (gcd) 0
That's right. If you think about it, that's implied by the definition: Non-integers are never evenly divisible by integers.
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/gcd.html