Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursion
#1
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.
#2
I've been through this before :l


Forum Jump:


Users browsing this thread: 1 Guest(s)