[erlang-questions] getting started with IO: question about syntax

Vlad Dumitrescu <>
Mon Oct 30 11:39:07 CET 2006


Hi,
Try like this

>     -module(factorial).
>     -export([main/0]).
>
>     main() ->
>         io:format("The factorial of 5 is: ~w~n", [fac(5)]).                %%% change here
>
>     fac(X) ->
>         if X == 1 ->
>              1;
>         true ->                %%% change here
>             X * fac(X - 1)
>         end.

Good luck!
/Vlad



More information about the erlang-questions mailing list