Created
March 3, 2016 10:25
-
-
Save exlee/98aa190587fc3920d379 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
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
defmodule FizzBuzz do | |
def print(no) when (rem(no, 15) == 0) do | |
IO.puts "FizzBuzz" | |
end | |
def print(no) when (rem(no, 3) == 0) do | |
IO.puts "Fizz" | |
end | |
def print(no) when (rem(no, 5) == 0) do | |
IO.puts "Buzz" | |
end | |
def print(no) do | |
IO.puts no | |
end | |
end | |
(1..100) | |
|> Enum.each(&FizzBuzz.print/1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment