You are viewing a single comment's thread. Return to all comments →
Elixir solution of 'Computing the GCD'
defmodule Solution do def gdc(x,y) do {min, max} = Enum.min_max([x,y]) reminder = rem(max, min) if reminder == 0, do: min, else: gdc(min, reminder) end def main do [x,y] = IO.gets('') |> String.split |> Enum.map(&String.to_integer(&1)) IO.puts gdc(x,y) end end Solution.main
Seems like cookies are disabled on this browser, please enable them to open this website
Computing the GCD
You are viewing a single comment's thread. Return to all comments →
Elixir solution of 'Computing the GCD'