+ 1
Please Help!
def G(x, b): if x == b: return 0 return 1 + G(x+1, b) print("G({},{}) = {}".format(3,100, G(3, 100))) I would like to know why 'G(3,100) = 97'?
2 Respuestas
+ 1
x=3
b=100
At return 1+G(4,100)
At return 96+G(99,100)
99 is passed to x which isn't equal to b
So now return is 97(G(100,100)
Now 100 is passed to x which equals to b so 0 is returned
return 97+0
So 97
+ 1
Thank you Abhay.