Skip to content

Instantly share code, notes, and snippets.

@exlee
Created March 3, 2016 10:25
Show Gist options
  • Save exlee/98aa190587fc3920d379 to your computer and use it in GitHub Desktop.
Save exlee/98aa190587fc3920d379 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
defmodule FizzBuzz do
def print(no) when (rem(no, 15) == 0) do
IO.puts "FizzBuzz"
end
def print(no) when (rem(no, 3) == 0) do
IO.puts "Fizz"
end
def print(no) when (rem(no, 5) == 0) do
IO.puts "Buzz"
end
def print(no) do
IO.puts no
end
end
(1..100)
|> Enum.each(&FizzBuzz.print/1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment