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 ->
        Cu;
    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.
>
>Regards.
>
Best regards,
Linker Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060327/90cdb812/attachment.htm>


More information about the erlang-questions mailing list