Find limit of recursion: Difference between revisions

m
Applesoft BASIC
m (Applesoft BASIC)
Line 147:
 
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
Each GOSUB consumes 6 bytes of stack space and when more than 25 levels have been reached and an <code>?OUT OF MEMORY ERROR</code> message is displayed.
<lang ApplesoftBasic> 100 PRINT "RECURSION DEPTH"
110 PRINT D" ";
120 LET D = D + 1
130 GOSUB 110"RECURSION</lang>
{{out}}
<pre>RECURSION DEPTH
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
?OUT OF MEMORY ERROR IN 120</pre>
==={{header|ZX Spectrum Basic}}===
On the ZX Spectrum recursion is limited only by stack space. The program eventually fails, because the stack is so full that there is no stack space left to make the addition at line 110:
413

edits