Created
September 18, 2015 12:20
-
-
Save GusGA/68796d26c9c8ce466067 to your computer and use it in GitHub Desktop.
FizzBuzz Code in Elixir
This file contains 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
defmodule FizzBuzz do | |
def start do | |
IO.inspect Enum.map(1..100, fizz_or_buzz) | |
end | |
def fizz_or_buzz(n) do | |
cond do | |
rem(n,15) == 0 -> "FizzBuzz" | |
rem(n,5) == 0 -> "Buzz" | |
rem(n,3) == 0 -> "Fizz" | |
true -> n | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment