I think the reason is simple. In the slow case, the fib_not_as_fast function fib_not_as_fast remembered. Inside the function, fib is called, which is not stored in memory. To be more detailed: when calculating fib_not_so_fast(24) inside the function, you have fib(22) + fib(23) . Both were not seen.
In fib_fast , however, you also use the memoised version also in recursion. So, in this case, fib_fast(24) needs to evaluate fib_fast(22) + fib_fast(23) . Both of these function calls already occurred when you calculated fib_fast(23) and were thus noticed.
Stibu source share