Skip to content

Instantly share code, notes, and snippets.

@sovetnik
Last active May 16, 2017 14:38
Show Gist options
  • Save sovetnik/f61b0e15740b12bde5c6f6d4c2a44017 to your computer and use it in GitHub Desktop.
Save sovetnik/f61b0e15740b12bde5c6f6d4c2a44017 to your computer and use it in GitHub Desktop.
FizzBuzz in Erlang
-module(fb).
-export([run/0, run/1, tell/1]).
run() -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,100)).
run(N) -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,N)).
tell(N) when N rem 15 == 0 -> 'FizzBuzz';
tell(N) when N rem 3 == 0 -> 'Fizz';
tell(N) when N rem 5 == 0 -> 'Buzz';
tell(N) when is_integer(N) -> N;
tell(_) -> 'Fuck this'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment