Skip to content

Instantly share code, notes, and snippets.

@tgautier
Created July 19, 2017 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgautier/caa9c537201ef96ee87cb7712c51ab4a to your computer and use it in GitHub Desktop.
Save tgautier/caa9c537201ef96ee87cb7712c51ab4a to your computer and use it in GitHub Desktop.
Just an Elixir FizzBuzz
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