Created
March 14, 2017 18:32
-
-
Save drincruz/5f59fe9f08c9825749dbaf6adc53fdf3 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir and Python
This file contains hidden or 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
def fizz_buzz(n) when 0 === rem(n, 3) and 0 === rem(n, 5) do | |
"FizzBuzz" | |
end | |
def fizz_buzz(n) when 0 === rem(n, 3), do: "Fizz" | |
def fizz_buzz(n) when 0 === rem(n, 5), do: "Buzz" | |
def fizz_buzz(n), do: n |
This file contains hidden or 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
def fizz_buzz(n): | |
if 0 == (n % 3) and 0 == (n % 5): | |
return "FizzBuzz" | |
elif 0 == (n % 3): | |
return "Fizz" | |
elif 0 == (n % 5): | |
return "Buzz" | |
else: | |
return str(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment