ok, i was doing some of my exam revision and came across this seires, it goes like this 1,1,2,3,5,8,13,21,34
now the logic behind it is
Fib1 = 1
Fib2 = 1
Fibn = (Fibn-2) + (Fibn-1)
i tried coding this in dark basic:
---------------------------------------------------------------------
sync on
n = 5
do
set cursor 200,200:print fib(n)
sync
loop
function fib(n)
if n > 2 then exitfunction fib(n-2) + fib(n-1)
endfunction 1
---------------------------------------------------------------------
for some reason fib(5) gives me 4 instead of 5, i'm sure i made a mistake somewhere but can't find where! help someone!
everyday of life is a new chapter that has already been fortold but is up to the soul to capture.