Skip to content

Instantly share code, notes, and snippets.

@imogenkinsman
Created September 30, 2017 18:01
Show Gist options
  • Save imogenkinsman/a21e684aa8e63816ebb1fe028224b23d to your computer and use it in GitHub Desktop.
Save imogenkinsman/a21e684aa8e63816ebb1fe028224b23d to your computer and use it in GitHub Desktop.
fizzbuzz in elixir
defmodule FizzBuzz do
def run do
1..100
|> Enum.each(& print(&1))
end
defp print(n) when rem(n, 15) == 0 do
IO.puts("fizzbuzz")
end
defp print(n) when rem(n, 3) == 0 do
IO.puts("fizz")
end
defp print(n) when rem(n, 5) == 0 do
IO.puts("buzz")
end
defp print(n) do
IO.puts(n)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment