Skip to content

Instantly share code, notes, and snippets.

@slofurno
Last active March 31, 2017 23:06
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 slofurno/a185945fcbcd913c77800aa20596a772 to your computer and use it in GitHub Desktop.
Save slofurno/a185945fcbcd913c77800aa20596a772 to your computer and use it in GitHub Desktop.
defmodule S do
def fizzbuzz(n), do: fb(3, 5, 1, n, [])
def fb(_fizz, _buzz, i, i, r), do: r |> Enum.reverse
def fb(i, i, i, j, r) do
fb(i+3, i+5, i+1, j, ["FizzBuzz"|r])
end
def fb(i, buzz, i, j, r) do
fb(i+3, buzz, i+1, j, ["Fizz"|r])
end
def fb(fizz, i, i, j, r) do
fb(fizz, i+5, i+1, j, ["Buzz"|r])
end
def fb(fizz, buzz, i, j, r) do
fb(fizz, buzz, i+1, j, [i|r])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment