Fizz Buzz in Erlang

Published on 04 October 2019 (Updated: 21 November 2023)

Welcome to the Fizz Buzz in Erlang page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

-module(fizz_buzz).
-export([main/1]).

% Run with: escript fizz_buzz.erl

main(_) ->
    fizz_buzz(1, 100).

fizz_buzz(N, Max) when N > Max -> [];
fizz_buzz(N, Max) when N rem 15 == 0 -> io:format("FizzBuzz~n", []), fizz_buzz(N+1, Max);
fizz_buzz(N, Max) when N rem 5 == 0 -> io:format("Buzz~n", []), fizz_buzz(N+1, Max);
fizz_buzz(N, Max) when N rem 3 == 0 -> io:format("Fizz~n", []), fizz_buzz(N+1, Max);
fizz_buzz(N, Max) -> io:format("~p~n", [N]), fizz_buzz(N+1, Max).

Fizz Buzz in Erlang was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.