Greatest common divisor: Difference between revisions
Content added Content deleted
Line 402: | Line 402: | ||
<lang lisp>(defn gcd |
<lang lisp>(defn gcd |
||
"(gcd a b) computes the greatest common divisor of a and b." |
|||
[a b] |
|||
(if (zero? b) |
|||
a |
|||
(recur b (mod a b))))</lang> |
|||
That <code>recur</code> call is the same as <code>(gcd b (mod a b))</code>, but makes use of Clojure's explicit tail call optimization. |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |