Skip to content

Instantly share code, notes, and snippets.

@danjac
Created March 25, 2016 20:15
Show Gist options
  • Save danjac/2dfb8cdc21cd1a79c42c to your computer and use it in GitHub Desktop.
Save danjac/2dfb8cdc21cd1a79c42c to your computer and use it in GitHub Desktop.
defmodule Fizzbuzz do
def run do
Enum.each(1..100, fn(num) -> IO.puts(get_message(num)) end)
end
def get_message(num) do
cond do
rem(num, 15) == 0 -> "fizzbuzz"
rem(num, 5) == 0 -> "buzz"
rem(num, 3) == 0 -> "fizz"
true -> Integer.to_string(num)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment