Created
September 19, 2016 15:08
-
-
Save tamanugi/ff52e177dc1e666ccc4a7066d38a7ae6 to your computer and use it in GitHub Desktop.
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 | |
list = 1..100 | |
for n <- list, do: fizzbuzz(n) | |
end | |
defp fizzbuzz(n) when rem(n,15) == 0 do | |
IO.puts ~s(FizzBuzz) | |
end | |
defp fizzbuzz(n) when rem(n,3) == 0 do | |
IO.puts ~s(Fizz) | |
end | |
defp fizzbuzz(n) when rem(n,5) == 0 do | |
IO.puts ~s(Buzz) | |
end | |
defp fizzbuzz(n) do | |
IO.puts ~s(#{n}) | |
end | |
end | |
FizzBuzz.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment