In some non pathological cases (like your), (latest) Lua will use tail call recursion, ie. it will just jump without pushing data in stack. So the number of recursion loops can be almost unlimited.
Tested with:
function f(i, l)
if i < l then
return f(i+1, l)
end
return i
end
local val1 = arg[1] or 1
local val2 = arg[2] or 100000000
print(f(val1 + 0, val2 + 0))
Also with:
function g(i, l)
if i >= l then
return i
end
return g(i+1, l)
end
and even tried cross-recursion (f calling g and g calling f...).
On Windows, Lua 5.1 uses around 1.1MB (constant) to run this, finishes in a few seconds.