Skip to content

Instantly share code, notes, and snippets.

@nwshane
Created November 27, 2017 17:29
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 nwshane/8b3f42ec1ccb59155b37830b089f50c6 to your computer and use it in GitHub Desktop.
Save nwshane/8b3f42ec1ccb59155b37830b089f50c6 to your computer and use it in GitHub Desktop.
FizzBuzz in the Elixir language
# Tested with Elixir 1.5.2
defmodule FizzBuzz do
defp fizzbuzzify(n) do
cond do
rem(n, 15) == 0 -> "FizzBuzz"
rem(n, 5) == 0 -> "Buzz"
rem(n, 3) == 0 -> "Fizz"
true -> n
end
end
def start(list) do
for n <- list, do: IO.puts fizzbuzzify n
end
end
FizzBuzz.start(1..100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment