Reply To: Recursion help – beginner

Home Forums Basic Erlang Recursion help – beginner Reply To: Recursion help – beginner

#54667

zsoci
Member

To give you an example, here is a quick and dirty solution for calculating factorials up to 5 decimals:
fac(N,Acc) ->
A = Acc * N,
if
A >= 10000 -> {A,N,Acc};
true -> fac(N+1,A)
end
.

you can call it by fac(1,1) (or fac(2,1))