Skip to content

Instantly share code, notes, and snippets.

@matthandlersux
Created November 27, 2012 22:06
Show Gist options
  • Save matthandlersux/4157469 to your computer and use it in GitHub Desktop.
Save matthandlersux/4157469 to your computer and use it in GitHub Desktop.
fizzbuzz in erlang
-module(fizzBuzz).
-export([fizzBuzz/0]).
fizzBuzz() ->
fizzBuzz(1,3,5).
fizzBuzz(100, _, _) ->
io:format("buzz~n");
fizzBuzz(Count, Count, Count) ->
io:format("fizzbuzz~n"),
fizzBuzz(Count + 1, Count + 3, Count + 5);
fizzBuzz(Count, Threes, Count) ->
io:format("buzz~n"),
fizzBuzz(Count + 1, Threes, Count + 5);
fizzBuzz(Count, Count, Fives) ->
io:format("fizz~n"),
fizzBuzz(Count + 1, Count + 3, Fives);
fizzBuzz(Count, Threes, Fives) ->
io:format("~w~n",[Count]),
fizzBuzz(Count + 1, Threes, Fives).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment