Seven Languages in Seven Weeks Part: Io Recursion Revisitedby justin on May 30, 2011, 8:06 a.m. UTC
I got bored and decided to do a better recursive Fibonacci method in Io. My previous one worked, but it had extra stuff in it that didn't need to be there. Here's a new one which has less garbage, but I think is still more efficient than the traditional recursive Fibonacci example that is used.
fib_recursive_2 := method(count,previous,current, if(count == nil, iteration := 0) if(previous == nil, previous := 0) if(current == nil, current := 1) if(count != 1, fib_recursive_2(count - 1, current, previous + current) ) current println )