+ 1
Retur fib(x-1)+fib(x-2),x(4)
(4-1)+(4-2) 3+2 5 So 5 is the correct answer
2 Answers
+ 1
Thank you....
0
fib(4-1) + fib(4-2)
= fib(3) + fib(2)
đ đ
=fib(3-1)+fib(3-2) + fib(2-1)+fib(2-2)
= fib(2)+ fib(1)+fib(1)+fib(0)
đ
=fib(2-1)+fib(2-2) + 1+1+1
=fib(1)+fib(0) + 3
=1+1+3
=5
Hoping that, If there is statement:
if(x==0 || x==1)
return 1;
Otherwise it is Infinite...