Using Recursion
This is an example program to show how can we make use of recursion in erlang to write a factorial program.
fact(0)-> 1; fact(N)-> N * fact(N-1).
Using Recursion (With Guard)
This is an example program to show how can we make use of guard with recursion in erlang to write a factorial program.
fact(N) when N == 0 -> 1; fact(N) when N > 0 -> N * fact(N-1).
Using Fold
This is an example program to show how can we make use of fold in erlang to write a factorial program.
lists:foldl(fun(A,B)-> A*B end , 1, [1,2,3,4,5,6,7,8,9,10]).