28th Feb 2023, 10:04 PM
Andrew The Python Slayer
Andrew The Python Slayer - avatar
8 ответов
+ 1
when y == 0, it starts to "unwind" The last call to the function .. 1 is returned... (the number in brackets is the number returned from the previous call 2 * (1) = 2; 2 * (2) = 4; 2 * (4) = 8 this helped me:- https://www.youtube.com/watch?v=kepBmgvWNDw&list=PLBlnK6fEyqRhX6r2uhhlubuF5QextdCSM&index=75
28th Feb 2023, 11:03 PM
rodwynnejones
rodwynnejones - avatar
+ 7
return x*f(x,y-1) Is called recursion. The function calls itself again but with an updated value, which leads to the exit condition.
28th Feb 2023, 10:25 PM
Ausgrindtube
Ausgrindtube - avatar
+ 6
I'm sorry, I'm not sure I understand your question. You have a function f(x, y) In that function there is an else condition which returns x* f(x,y-1) That return calls the original function again but with a new y value. If we put the numbers in: 2* f(2, 3-1) 2* f(2, 2-1) 2* f(2, 1-1) -> now y == 0, so it will end
28th Feb 2023, 10:41 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Thanks to everyone, I finally figured it out
1st Mar 2023, 11:50 AM
Andrew The Python Slayer
Andrew The Python Slayer - avatar
+ 1
Although the video is in about "C", the logic is the same. Pay particular attention to the last 5 min.
28th Feb 2023, 11:10 PM
rodwynnejones
rodwynnejones - avatar
+ 1
print("Wow you have created pow() function.") If you want to check: print("Check") else: print("scroll up")
1st Mar 2023, 11:48 AM
Nikoloz Kuprashvili
Nikoloz Kuprashvili - avatar
0
But, why( x* (x,y-1)) change to ( x* (x*(y-1))?
28th Feb 2023, 10:29 PM
Andrew The Python Slayer
Andrew The Python Slayer - avatar
0
where does the action come from instead of a comma
28th Feb 2023, 10:29 PM
Andrew The Python Slayer
Andrew The Python Slayer - avatar