title: Ruby. Range:Each change value
body: <p>I'm trying to write a siple script, that calculates fibonacci numbers in a loop:</p>
  
  <pre><code>def fib(v)
   return v if v &lt; 2
   (fib(v-2) + fib(v-1))
  end
  
  [0..15].each do |i|
    puts "#{fib(i-1)} "
  end
  </code></pre>
  
  <p>But this code fails because i-1 cannot be executed, as i has type Range. What should I do with it? I know, there are many other ways to calculate fibonacci numbers, but I need this code to work, not to rewrite it.</p>