defmodule Main do def getsAll(device \\ :stdio, prompt), do: getsAll(device, prompt, "") defp getsAll(device, prompt, input) do x = IO.gets(device, prompt) case x do {:error, _} -> x :eof -> input _ -> getsAll(device, prompt, input <> x) end end def sum(n), do: sum(n, 1) defp sum(n, acc) do case n do 1 -> acc _ -> sum(n - 1, acc + n) end end def main do inputs = getsAll(nil) |> String.split n = inputs |> Enum.at(0) |> String.to_integer IO.puts sum(n) end end