+ 1
For following recursive function,will recursion work for fib(x-1) first & then on fib(x-2) or will recursion work simultaneously
def fib(x): if x == 0 or x == 1: return 1 else: return fib(x-1) + fib(x-2) print(fib(4))
3 ответов
+ 1
since python starts left to right then fib(x-1) works first
+ 1
Recursion will start from left to right only
So fib(x-1) recurses first
then by fib(x-2)
but I am not clear with this iteration if any one knew help me with it
0
I still don't follow this code. The output is 5, but how? Tried inserting some print statements but still not clicking for me