Skip to content

Instantly share code, notes, and snippets.

@stevenwilkin
Created August 28, 2017 18:16
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 stevenwilkin/73f3cb572e7e65f9c487135d2e75afe4 to your computer and use it in GitHub Desktop.
Save stevenwilkin/73f3cb572e7e65f9c487135d2e75afe4 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
#!/usr/bin/env elixir
defmodule FizzBuzz do
def check(x) when (rem(x, 3) == 0) and (rem(x, 5) == 0) do
IO.puts "FizzBuzz"
end
def check(x) when rem(x, 3) == 0 do
IO.puts "Fizz"
end
def check(x) when rem(x, 5) == 0 do
IO.puts "Buzz"
end
def check(x) do
IO.puts x
end
def run do
Enum.each(1 .. 100, &check/1)
end
end
FizzBuzz.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment