Skip to content

Instantly share code, notes, and snippets.

@plukevdh
Last active August 29, 2015 14:16
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 plukevdh/6e95765b65c94f9c07f7 to your computer and use it in GitHub Desktop.
Save plukevdh/6e95765b65c94f9c07f7 to your computer and use it in GitHub Desktop.
Fizz Buzz
defmodule Streem do
def fb(n) when rem(n,15) == 0, do: "FizzBuzz"
def fb(n) when rem(n,3) == 0, do: "Fizz"
def fb(n) when rem(n,5) == 0, do: "Buzz"
def fb(n), do: n
end
defmodule Streem do
def fb(n) do
case n do
n when rem(n, 15) == 0 -> "FizzBuzz"
n when rem(n, 3) == 0 -> "Fizz"
n when rem(n, 5) == 0 -> "Buzz"
_ -> n
end
end
end
0..1000
|> Enum.map &(Streem.fb(&1))
|> IO.puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment