Created
October 15, 2013 13:09
-
-
Save jukworks/6991319 to your computer and use it in GitHub Desktop.
Euclid GCD(greatest common divisor) in Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn euclid-gcd [m n] | |
(let [r (mod m n)] | |
(if (zero? r) | |
n | |
(euclid-gcd n r)))) | |
;; (euclid-gcd 2166 6099) => 57 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment