Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Last active May 7, 2020 13:18
Show Gist options
  • Save karlosmid/5308e03a706f2199b3de91e38c804e06 to your computer and use it in GitHub Desktop.
Save karlosmid/5308e03a706f2199b3de91e38c804e06 to your computer and use it in GitHub Desktop.
defmodule FizzBuzz do
def up_to(n) when n > 0, do: 1..n |> Enum.map(&fizz_buzz/1)
def fizz_buzz(n) do
case {rem(n,3),rem(n,5),n} do
{0,0,_} -> FizzBuzz
{0,_,_} -> Fizz
{_,0,_} -> Buzz
{_,_,_} -> n
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment