Hacker News new | ask | show | jobs
by mjmas 175 days ago

  function fib(a)
    return countfib(1,1,a)
  end
  function countfib(a,b,n)
    if n == 1 then
      return a
    else
      -- proper tail call
      return countfib(b,a+b,n-1)
    end
  end
  print(fib(6)) --> 8