+ 4
I dont understand this quiz question
I don't know how you would get his answer https://code.sololearn.com/c7qP2uh7y5wh/?ref=app
4 Answers
+ 21
Recursion.
def kys (x):
if x == 0:
return 0
else:
return kys(x-1)+100
# i.e. :
# kys(3)
# when expanded, is
# -> kys(3-1) + 100
# -> kys(2-1) + 100 + 100
# -> kys(1-1) + 100 + 100 + 100
# -> 0 + 100 + 100 + 100
# -> 300
+ 14
Exactly as reflected in my answer.
kys(1-1) returns 0
+ 3
oh I understand now it returns 0 which the 100s get added to it
0
but when x = 0 wouldn't it just return 0