Elixir 練習問題 ModulesAndFunctions-5
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
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