Skip to content

Instantly share code, notes, and snippets.

@animato
Last active February 20, 2023 13:03
Show Gist options
  • Save animato/6cb60afe6c50006d4790f6da7d227a04 to your computer and use it in GitHub Desktop.
Save animato/6cb60afe6c50006d4790f6da7d227a04 to your computer and use it in GitHub Desktop.
# 5-2 인자 세 개를 받는 함수
fizz_buzz = fn
0, 0, _ -> "FizzBuzz"
0, _, _ -> "Fizz"
_, 0, _ -> "Buzz"
_, _, a -> a
end
# 5-3 FizzBuzz 함수
fizzbuzz = fn
n -> fizz_buzz.(rem(n, 3), rem(n, 5), n)
end
IO.puts fizzbuzz.(10)
IO.puts fizzbuzz.(11)
IO.puts fizzbuzz.(12)
IO.puts fizzbuzz.(13)
IO.puts fizzbuzz.(14)
IO.puts fizzbuzz.(15)
IO.puts fizzbuzz.(16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment