diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2017-07-15 22:46:01 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2017-07-15 22:46:25 +0300 |
commit | 0b0c13b1cdf0427f604ff3e1df8963df7237a527 (patch) | |
tree | 1371eba7220c560431203ddbfe9fcd7c12bb4feb | |
parent | c70c0d4418ca756f9b6fc660d0aa9d54e6f025ae (diff) | |
download | gcd-0b0c13b1cdf0427f604ff3e1df8963df7237a527.tar.gz |
Clojure
-rw-r--r-- | gcd.clj | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +; SYNOPSIS: +; +; $ clojure gcd.clj 11 22 33 121 +; 11 +; +; or: +; +; $ java -cp clojure-1.8.0.jar clojure.main gcd.clj 11 22 33 121 +; 11 +; + +(defn gcd2 [a b] + (if (zero? b) + a + (gcd2 b (mod a b)))) + +(defn gcdn [aa] (reduce gcd2 aa)) + +(println + (gcdn + (map #(Integer/parseInt %) *command-line-args*))) + |