I\'m trying to implement the following function, but it keeps giving me the stack level too deep (SystemStackError) error.
stack level too deep (SystemStackError)
Any ideas what the problem mi
Joining the Fibonacci train:
Regular:
def fib(num) return num if (num < 2) else fib(num-1) + fib(num-2) end
With caching:
module Fib @fibs = [0,1] def self.calc(num) return num if (num < 2) else @fibs[num] ||= self.calc(num-1) + self.calc(num-2) end end