Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created June 20, 2010 10:55
Show Gist options
  • Save michalmarczyk/445740 to your computer and use it in GitHub Desktop.
Save michalmarczyk/445740 to your computer and use it in GitHub Desktop.
(defn gcd
([x y]
(cond (zero? x) y
(< y x) (recur y x)
:else (recur x (rem y x))))
([x y & zs]
(reduce gcd (gcd x y) zs)))
(defn lcm
([x y] (/ (* x y) (gcd x y)))
([x y & zs]
(reduce lcm (lcm x y) zs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment