1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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*)))