Last active
August 29, 2015 14:19
-
-
Save shizone/ced7bed01abdae49debc to your computer and use it in GitHub Desktop.
最大公約数
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
(defn greatest-common-divisor [x y] | |
(loop [n (min x y)] | |
(if (and (= (rem x n) 0) (= (rem y n) 0)) | |
n | |
(recur (dec n)) | |
) | |
) | |
) | |
(greatest-common-divisor 12 18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment