Finding the nth Fibonacci number using recursive technique
Firstly, a minor point. fact? Have you refactored a recursive factorial method and forgotten to rename the accumulator?



That aside, I find this hilarious. Almost certainly the intended solution was along the lines of

def fibonacci(num)
  if num &lt; 2
    return 1
  else
    return fibonacci(num - 2) + fibonacci(num - 1)
  end
end


which is the naïve recursive definition, and a classic teaching example of how naïve implementations can be insanely inefficient.

Your answer meets the rather vague spec (it is recursive), but is much better than the intended solution because it takes linear time (or maybe quadratic if push is linear, but I doubt it) rather than exponential.

If you want an additional challenge, here are two:


Your solution takes linear time and linear space. Can you modify it to take linear time and constant space?
Can you modify it further to take logarithmic time and constant space?


Hint for the second one:


   \$F(m+n) = F(m+1) F(n) + F(m) F(n-1)\$