4 ms·
Pretend you're a compiler, what changes would you make to this to make it tail recursive: fib(0) -> 1; fib(1) -> 1; fib(N) -> fib(N-1) + fib(N-2). Rules
by Jtsummers 8y ago
Pretend you're a compiler, what changes would you make to this to make it tail recursive:
fib(0) -> 1;
fib(1) -> 1;
fib(N) -> fib(N-1) + fib(N-2).
Rules: Making a second function (fib_help) is permitted. Shouldn't use any more memory than this one uses.
- FeepingCreature 8y agoFun challenge. https://paste.pound-python.org/show/m403qNkpS5I8dnYjJGJq/ https://paste.pound-python.org/show/m403qNkpS5I8dnYjJGJq/ I wanna see the compiler that gets that.