+ 1

why 5 output of this function

def fb(n): if n == 0: return 0 elif n ==1: return 1 else return(fb(n-1) + fb(n-2)) print(fb(5))

19th Jul 2018, 3:23 AM
khjoony
khjoony - avatar
1 Resposta
+ 8
fb(5) fb(4)+fb(3) fb(3)+fb(2)+fb(2)+fb(1) fb(2)+fb(1)+fb(1)+fb(0)+fb(1)+fb(0)+1 fb(1)+fb(0)+1+1+0+1+0+1 1+0+1+1+0+1+0+1 5
19th Jul 2018, 3:27 AM
Hatsy Rei
Hatsy Rei - avatar