rubyx-debugger/codes/a_fibo_recur.soml
Torsten Ruger cad3deab3a add working fibonacci examples, while and recursive
for fibo(10) the difference is 270 vs 6500 instructions, a lot
apparently there are as many calls as the fibs result, i.e. 55, for
recursive
2015-11-05 13:58:59 +02:00

23 lines
370 B
Plaintext

class Object
int fibonaccir( int n )
if_plus( n - 1 )
int tmp
tmp = n - 1
int a = fibonaccir( tmp )
tmp = n - 2
int b = fibonaccir( tmp )
return a + b
else
return n
end
end
int fib_print(int n)
int fib = fibonaccir( n )
fib.putint()
return fib
end
int main()
return fib_print(10)
end
end