Skip to content

Instantly share code, notes, and snippets.

@tamanugi
Created September 19, 2016 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamanugi/ff52e177dc1e666ccc4a7066d38a7ae6 to your computer and use it in GitHub Desktop.
Save tamanugi/ff52e177dc1e666ccc4a7066d38a7ae6 to your computer and use it in GitHub Desktop.
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