Skip to content

Instantly share code, notes, and snippets.

@st23am
Last active December 31, 2015 01:38
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 st23am/7914932 to your computer and use it in GitHub Desktop.
Save st23am/7914932 to your computer and use it in GitHub Desktop.
Fizzbuzz in Elixir
#FizzBuzz with module, named functions, and no conditional
defmodule Kata do
def fizzbuzz( 0, 0, _ ), do: "FizzBuzz"
def fizzbuzz( 0, _, _ ), do: "Fizz"
def fizzbuzz( _, 0, _ ), do: "Buzz"
def fizzbuzz( _, _, x ), do: "#{ x }"
def fizzbuzz(n) do
fizzbuzz(rem(n, 3), rem(n, 5), n)
end
end
Enum.map(1..100, &(IO.puts Kata.fizzbuzz(&1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment