0
Explain this python code, how it results 7?
def fact(x): If x ==1: return 2 else: return x + fact(x - 1) print(fact(3))
6 Respostas
+ 1
>>>fact(3)
>>>3 + fact(2) #3
>>>2 + fact(1) #2
x is now == 1 so...
2 #2
The sum of all the iterations (the numbers after the comments) is 7.
+ 2
fact3 = 3 + fact2 = 3+2+fact1 = 3+2+2=7
0
Isaac Clarke what do you mean?
0
Thanks Slick and Oma Fold