Created
May 15, 2017 19:05
-
-
Save dliberalesso/611b0eecc09d09b0078abdd7a2a2c2a3 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
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 compute(n), do: fb(n, rem(n, 3), rem(n, 5)) | |
defp fb(_, 0, 0), do: "FizzBuzz" | |
defp fb(_, 0, _), do: "Fizz" | |
defp fb(_, _, 0), do: "Buzz" | |
defp fb(n, _, _), do: n | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment