Created
March 25, 2016 20:15
-
-
Save danjac/2dfb8cdc21cd1a79c42c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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