Skip to content

Instantly share code, notes, and snippets.

@MaroShim
Last active November 1, 2016 07:57
Show Gist options
  • Save MaroShim/6a6a7cf9dc86d2bd18a2a6c7ff031b76 to your computer and use it in GitHub Desktop.
Save MaroShim/6a6a7cf9dc86d2bd18a2a6c7ff031b76 to your computer and use it in GitHub Desktop.
# less than 1000, multiple of 3 or 5
defmodule Problem1 do
def solve(limit) do
1..(limit-1)
|> Enum.filter(fn x -> ((rem(x, 3) == 0) || (rem(x, 5) == 0)) end)
|> Enum.reduce(0, &(&1 + &2))
end
def print do
IO.puts solve(1000)
end
end
Problem1.print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment