Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solving FizzBuzz without if in Elixir
fizz_word = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, third) -> third
end
fizz_buzz = fn n -> fizz_word.(rem(n, 3), rem(n, 5), n) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment