title: Ruby Fibonacci algorithm
body: <p>The following is a method I wrote to calculate a value in the Fibonacci sequence:</p>
  
  <pre><code>def fib(n)
  
      if n == 0
          return 0
      end
      if n == 1
          return 1
      end
  
      if n &gt;= 2
          return fib(n-1) + (fib(n-2))
      end
  
  end
  </code></pre>
  
  <p>It works uptil n = 14, but after that I get a message saying the program is taking too long to respond (I'm using repl.it). Anyone know why this is happening?</p>