Last active
July 23, 2017 19:22
-
-
Save w-k-s/8f130e3e7296c2fc76851f5f908c3f41 to your computer and use it in GitHub Desktop.
Greatest Common Denominator
This file contains hidden or 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
;tutorial: http://www.braveclojure.com/do-things/ | |
(defn gcd | |
[a b] | |
(loop [dividend (max a b), divisor (min a b)] | |
(def remainder (rem dividend divisor)) | |
(if (= remainder 0) | |
divisor | |
(recur divisor remainder))) | |
) | |
(gcd 32 5);1 | |
(gcd 48 18);6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment