Newbie questions

Nick Linker xlcr@REDACTED
Mon Mar 27 05:26:47 CEST 2006

Javier París Fernández wrote:

I made my version, but after posting the question :-)

    fib(0) -> 0;
    fib(1) -> 1;
    fib(N) ->
        fib(N, 0, 1).
    fib(I, Pr, Cu) when I =< 1 ->
    fib(I, Pr, Cu) ->
        fib(I-1, Cu, Pr + Cu).

Thank you for your answer nonetheless.

>However, as Kostis said, this has more to do with having two recursive calls 
>each time than with it being tail recursion or not. If you try to see how it 
>evaluated, the number of recursive calls expands exponentially.
Best regards,
Linker Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list