Created
August 9, 2016 11:16
-
-
Save tommyip/8b2c6787081d79a7d9653675d8e68e4f to your computer and use it in GitHub Desktop.
FizzBuzz test with no conditional statement in Erlang
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
-module(fizzbuzz). | |
-export([fizzbuzz/0]). | |
fizzbuzz() -> N = 1, fizzbuzz({N rem 3, N rem 5, N}). | |
fizzbuzz({N3, N5, N}) when N =< 100 -> | |
case {N3, N5, N} of | |
{0, 0, _} -> io:format("FizzBuzz~n"); | |
{0, _, _} -> io:format("Fizz~n"); | |
{_, 0, _} -> io:format("Buzz~n"); | |
{_, _, N} -> io:format("~w~n", [N]) | |
end, | |
fizzbuzz({(N+1) rem 3, (N+1) rem 5, (N+1)}); | |
fizzbuzz({_, _, _}) -> finished. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment