C+- Recursivity error
Closed this issue · 0 comments
Leonardo16AM commented
The recursivity fails due the variables created in each step. Aparently the context of the variables created in the recursivity affects the parent context.
This case breaks the code:
/run def int fib(int n){
int p1=n-1;
int p2=n-2;
if(n==0|n==1){return 1;}
if(n<0){return 0;}
int f1=fib(p1);
int f2=fib(p2);
notify(p1+" ; "+p2);
notify(f1+" _ "+f2);
return f1+f2;
}
/run notify(fib(2));