Skip to content

Instantly share code, notes, and snippets.

@karakfa
Created October 19, 2016 14:55
Show Gist options
  • Save karakfa/40372466c7e676b60d549d53d98523e7 to your computer and use it in GitHub Desktop.
Save karakfa/40372466c7e676b60d549d53d98523e7 to your computer and use it in GitHub Desktop.
-- Knuth's way
-- from the blog post http://videlalvaro.github.io/2016/10/knuth-first-erlang-programmer.html
gcd m n = f m n 0 1
where f m n r 1 = f m n (mod m n) 2
f m n 0 2 = n
f m n r 2 = f n r r 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment