Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Functional FizzBuzz
defmodule FizzBuzz do
def upto(n) when n > 0, do: 1..n |> Enum.map(&fizzbuzz/1)
defp fizzbuzz(n) when rem(n, 15) == 0, do: "FizzBuzz"
defp fizzbuzz(n) when rem(n, 3) == 0, do: "Fizz"
defp fizzbuzz(n) when rem(n, 5) == 0, do: "Buzz"
defp fizzbuzz(n), do: n
end
@lexa76
Copy link

lexa76 commented Dec 20, 2014

Fizz buzz

@lexa76
Copy link

lexa76 commented Dec 20, 2014

Vote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment