Elixir 練習問題 ModulesAndFunctions-5

2017年2月6日
1 分
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