Let’s say i have this function:
local function f(x)
if x > 2000000 then
return x
end
return f(x + 1)
end
print(f(1))
The problem is after it firing 200 times a c stack overflow appears. How can i fire this functions recursively without that happening?
lumizk
(luz)
#3
when you use recursion you must be sure that you are not going to overflow the stack. if you are not sure it is better to use loops.
local function f(x)
while x <= 2000000 do
x = x + 1
end
return x
end
1 Like
system
(system)
Closed
#4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.