Created
July 19, 2017 09:09
-
-
Save tgautier/caa9c537201ef96ee87cb7712c51ab4a to your computer and use it in GitHub Desktop.
Just an Elixir FizzBuzz
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 fizzbuzz(n) do | |
Enum.map 1..n, &fizzify(&1) | |
end | |
def fizzify(i) do | |
case {rem(i, 3), rem(i, 5), i} do | |
{0, 0, _} -> "FizzBuzz" | |
{0, _, _} -> "Fizz" | |
{_, 0, _} -> "Buzz" | |
{_, _, i} -> i | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment