EUCLID'S ALGORITHM

Scheme has a predefined procedure gcd for computing the greatest common divisor of zero or more integers. However, we should pause to admire the bare beauty of Euclid's algorithm, as expressed in Scheme:

(define gcd
  (lambda (m n)
    (if (zero? n) m (gcd n (remainder m n)))))


This document is available on the World Wide Web as

http://www.math.grin.edu/~stone/events/scheme-workshop/gcd.html


created July 9, 1995
last revised June 21, 1996

John David Stone (stone@math.grin.edu)