Created
November 27, 2017 17:29
-
-
Save nwshane/8b3f42ec1ccb59155b37830b089f50c6 to your computer and use it in GitHub Desktop.
FizzBuzz in the Elixir language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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