Last active
May 7, 2020 13:18
-
-
Save karlosmid/5308e03a706f2199b3de91e38c804e06 to your computer and use it in GitHub Desktop.
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
defmodule FizzBuzz do | |
def up_to(n) when n > 0, do: 1..n |> Enum.map(&fizz_buzz/1) | |
def fizz_buzz(n) do | |
case {rem(n,3),rem(n,5),n} do | |
{0,0,_} -> FizzBuzz | |
{0,_,_} -> Fizz | |
{_,0,_} -> Buzz | |
{_,_,_} -> n | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment