Skip to content

Instantly share code, notes, and snippets.

@ronan-mch
Created October 21, 2015 10:16
Show Gist options
  • Save ronan-mch/6d1a83c358e1e9c9504c to your computer and use it in GitHub Desktop.
Save ronan-mch/6d1a83c358e1e9c9504c to your computer and use it in GitHub Desktop.
Elixir FizzBuzz
defmodule FizzBuzz do
def write(i) when (rem(i, 3) == 0 and rem(i, 5) == 0) do
IO.puts "FizzBuzz"
end
def write(i) when rem(i, 3) == 0 do
IO.puts "Fizz"
end
def write(i) when rem(i, 5) == 0 do
IO.puts "Buzz"
end
def write(i) do
IO.puts i
end
end
Enum.map(1..20, fn x -> FizzBuzz.write(x) end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment