Created
March 10, 2017 20:34
-
-
Save raphamorim/c01eaf18bc25224051a8228b57e88e18 to your computer and use it in GitHub Desktop.
Input SUM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Solution do | |
defp sum(a, b), do: a + b | |
def main() do | |
a = IO.gets("") |> String.strip |> String.to_integer | |
range = 1..a | |
Enum.reduce(range, 0, fn(x, acc) -> sum(acc, IO.gets("") |> String.strip |> String.to_integer) end) | |
|> IO.puts | |
end | |
end | |
Solution.main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment