Created
August 18, 2012 16:29
-
-
Save tfkd/3388162 to your computer and use it in GitHub Desktop.
FizzBuzz
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
%% fizzbuzz | |
fizzbuzz(N) -> | |
if | |
N rem 15 == 0 -> | |
io:fwrite("~w~n", [fizzbuzz]); | |
N rem 3 == 0 -> | |
io:fwrite("~w~n", [fizz]); | |
N rem 5 == 0 -> | |
io:fwrite("~w~n", [buzz]); | |
true -> | |
io:fwrite("~w~n", [N]) | |
end. | |
run_fizzbuzz(N) -> | |
run_fizzbuzz(N, 1). | |
run_fizzbuzz(N, N) -> | |
fizzbuzz(N); | |
run_fizzbuzz(N, M) -> | |
fizzbuzz(M), | |
run_fizzbuzz(N, M + 1). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment