Skip to content

Instantly share code, notes, and snippets.

@podviaznikov
Created October 30, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podviaznikov/7235142 to your computer and use it in GitHub Desktop.
Save podviaznikov/7235142 to your computer and use it in GitHub Desktop.
The greatest common divisor (GCD) of two integers: x and y. http://people.cis.ksu.edu/~schmidt/301s12/Exercises/euclid_alg.html. Clojure implementation.
(defn gdc [x y]
(if (= x y)
x
(if (> x y)
(recur (- x y) y)
(recur (- y x) x))))
(gdc 10, 100) ; 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment