I dont understand this quiz question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

I dont understand this quiz question

I don't know how you would get his answer https://code.sololearn.com/c7qP2uh7y5wh/?ref=app

5th Nov 2017, 2:35 PM
Curly Fries
Curly Fries - avatar
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
5th Nov 2017, 2:42 PM
Hatsy Rei
Hatsy Rei - avatar
+ 14
Exactly as reflected in my answer. kys(1-1) returns 0
5th Nov 2017, 2:50 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
oh I understand now it returns 0 which the 100s get added to it
5th Nov 2017, 2:51 PM
Curly Fries
Curly Fries - avatar
0
but when x = 0 wouldn't it just return 0
5th Nov 2017, 2:49 PM
Curly Fries
Curly Fries - avatar