defmodule GCD do def gcd(x, 0), do: x def gcd(x, y), do: gcd(y, rem(x, y)) end
iex(3)> c "practice_6_5.exs" [GCD] iex(4)> GCD.gcd(45, 60) 15
takatoh's blog – Learning programming languages.
defmodule GCD do def gcd(x, 0), do: x def gcd(x, y), do: gcd(y, rem(x, y)) end
iex(3)> c "practice_6_5.exs" [GCD] iex(4)> GCD.gcd(45, 60) 15