Jump to content

Find limit of recursion: Difference between revisions

Added Befunge example.
mNo edit summary
(Added Befunge example.)
Line 292:
No room
</pre>
 
=={{header|Befunge}}==
 
In Befunge, the limit of recursion is essentially the depth of the stack. The program below calculates that limit by repeatedly pushing values until the stack overflows. After every iteration, it writes out the count of values pushed so far, so once the stack eventually does overflow, the last value output should tell you the depth that was reached.
 
Most interpreters allocate their stack on the global heap, so the size of the stack will depend on available memory, and on a modern system you're likely to run out of patience long before you run out of memory. That said, there have been some interpreters with a fixed stack depth - as low as 199 even - but that isn't a common implementation choice.
 
<lang befunge>1>1#:+#.:_@</lang>
 
=={{header|Bracmat}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.