Created
July 6, 2015 21:27
-
-
Save bryanwoods/337f173935a35968fe29 to your computer and use it in GitHub Desktop.
Logic free FizzBuzz in Elixir
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
fizz_word = fn | |
0, 0, _ -> "FizzBuzz" | |
0, _, _ -> "Fizz" | |
_, 0, _ -> "Buz" | |
_, _, x -> x | |
end | |
fizz_buzz = fn n -> fizz_word.(rem(n, 3), rem(n, 5), n) end | |
Enum.each 1..100, fn(n) -> IO.puts(fizz_buzz.(n)) end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment