Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Created April 18, 2015 06:34
Show Gist options
  • Save jamesdavidson/8fe910dbad3cf00b785b to your computer and use it in GitHub Desktop.
Save jamesdavidson/8fe910dbad3cf00b785b to your computer and use it in GitHub Desktop.
Euclid's algorithm
-- Euclid's algorithm for calculating the greatest-common-divisor.
gcd :: Integer -> Integer -> Integer
gcd x y =
if r == 0 then y else (gcd y r)
where r = (mod x y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment