Created
October 21, 2015 10:16
-
-
Save ronan-mch/6d1a83c358e1e9c9504c to your computer and use it in GitHub Desktop.
Elixir FizzBuzz
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 write(i) when (rem(i, 3) == 0 and rem(i, 5) == 0) do | |
IO.puts "FizzBuzz" | |
end | |
def write(i) when rem(i, 3) == 0 do | |
IO.puts "Fizz" | |
end | |
def write(i) when rem(i, 5) == 0 do | |
IO.puts "Buzz" | |
end | |
def write(i) do | |
IO.puts i | |
end | |
end | |
Enum.map(1..20, fn x -> FizzBuzz.write(x) end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment