Greatest common divisor: Difference between revisions

Line 1,898:
Racket provides a built-in gcd function. Here's a program that computes the gcd of 14 and 63:
 
<lang Racketracket>#lang racket
 
(gcd 14 63)</lang>
Line 1,904:
Here's an explicit implementation. Note that since Racket is tail-calling, the memory behavior of this program is "loop-like", in the sense that this program will consume no more memory than a loop-based implementation.
 
<lang Racketracket>#lang racket
 
;; given two nonnegative integers, produces their greatest