title: How to create Fibonacci sequence in Lua?
body: <p>I wrote a small script that creates Fibonacci sequence and returns a sum of all even integers.</p>
  
  <pre><code>function even_fibo()
    -- create Fibonacci sequence
    local fib = {1, 2}  -- starting with 1, 2
    for i=3, 10 do
      fib[i] = fib[i-2] + fib[i-1]
    end
    -- calculate sum of even numbers
    local fib_sum = 0
    for _, v in ipairs(fib) do
      if v%2 == 0 then
        fib_sum = fib_sum + v
      end
    end
    return fib_sum
  end
  
  fib = even_fibo()
  print(fib)
  </code></pre>
  
  <p>The function creates the following sequence:
  <code>1, 2, 3, 5, 8, 13, 21, 34, 55</code></p>
  
  <p>And returns the sum of its even numbers: <code>44</code></p>
  
  <p>However, when I change the stop index from <code>10</code> to <code>100</code>, in <code>for i=3, 100 do</code> the returned sum is negative <code>-8573983172444283806</code> because the values become too big.
  Why is my code working for <code>10</code> and not for <code>100</code>?</p>