#How do this pls help

6 messages · Page 1 of 1 (latest)

tight crane
orchid meteorBOT
#

This post has been reserved for your question.

Hey @tight crane! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

tight lava
#

Well, one way to better understand any exercise, is writing down one iteration at a time, possibly with some input.

So, let's give it a try with some simple numbers. Let's say:
a=3
b=3

b is equals to 1?
No, so I go into the else branch.

return a + mystery(a, b-1)
so,
return 3 + mystery(3, 2)
So, we have to mentally PAUSE things here, and solve the same function once again with these new inputs
Let's call this Pause-point-1 and go on, calling that function again.

At this stage:
a = 3
b = 2

b is equals to 1?
No, so I go into the else branch.
return a + mystery(a, b-1)
so
return 3 + mystery(3, 1)

So, we have to mentally PAUSE things here again, and solve the same function once again with these new inputs
Let's call this Pause-point-2 and go on, calling that function again.

At this stage:
a = 3
b = 1

b is equals to 1?
YES! Finally!
I return a
so, return 3

Now, we can UNPAUSE the least thing we paused.
What was that?
it was at Pause-point-2:

we had paused the code:
return 3 + mystery(3, 1)
but now we know that mystery(3,1) gave a result of 3
so, this became: return 3 + 3
basically return 6

We can now go on, and UNPAUSE the remaining thing we paused.
It wat at Pause-point-1 on the code:
return 3 + mystery(3, 2)

now, we know that mystery(3,2) gives us 6, so it became:

return 3 + 6
basically return 9

We have nothing else paused, so the algorithm finally ends, and the result is 9.

orchid meteorBOT
# tight crane thank you sir

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.