Skip to content

Instantly share code, notes, and snippets.

@omegahm
Created May 19, 2015 16:23
Show Gist options
  • Save omegahm/8feb8270b1969a2d2dd3 to your computer and use it in GitHub Desktop.
Save omegahm/8feb8270b1969a2d2dd3 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
defmodule FizzBuzz do
def fizzbuzz(n) do
whichfizz(rem(n, 3), rem(n, 5), n)
end
defp whichfizz(0, 0, _), do: "FizzBuzz"
defp whichfizz(0, _, _), do: "Fizz"
defp whichfizz(_, 0, _), do: "Buzz"
defp whichfizz(_, _, n), do: n
end
IO.inspect Enum.map(1..100, &FizzBuzz.fizzbuzz/1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment