Programming-Idioms

History of Idiom 74 > diff from v10 to v11

Edit summary for version 11 :

Version 10

2015-09-03, 16:30:35

Version 11

2015-09-04, 13:35:24

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Code
defmodule Gcd do
  def gcd(x, 0), do: x
  def gcd(x, y), do: gcd(y, rem(x,y))
end

x = Gcd.gcd(a, b)