Programming-Idioms

History of Idiom 74 > diff from v25 to v26

Edit summary for version 26 :
New Clojure implementation by user [el_memorioso]

Version 25

2019-01-25, 11:48:54

Version 26

2019-09-26, 16:38:11

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Code
(defn gcd [a b]
  (if (zero? b)
    b
    (recur b (mod a b))))