Dark Signs J forum
Recursion - Printable Version

+- Dark Signs J forum (https://darksigns.pf-control.de/forum)
+-- Forum: DarkSignsJ (https://darksigns.pf-control.de/forum/forumdisplay.php?fid=3)
+--- Forum: Dark Script (https://darksigns.pf-control.de/forum/forumdisplay.php?fid=6)
+--- Thread: Recursion (/showthread.php?tid=302)



Recursion - flederohr - 03-17-2020

Calculates fibonacci numbers and prints them in the console

save script as fibo
and compile 
Code:
compile fibo

Code:
var i
varexists ext1
if varexists
varexists ext2
if varexists
print %i%
skipline
!i=ext1+ext2
fibo %ext2% %i%
endif
else
!i=1
print %i%
skipline
fibo %i% %i%
endif
 on compiling the first time a warning is posted
Code:
Error: "/fibo" is not a valid dsscript

This warning is just appearing as on compile time the self referenced script file is not jet available.

Just execute the compiled script

Code:
> fibo

At some point the message "StackOverflowError" is shown.
The script execution is terminated at this point due to the stack limit on the parser has been reached.


RE: Recursion - Hugofirst1994 - 11-25-2020

I've been through this before :l