0

please help me to how to work this code

def sum(x,y): if(y==0): return x; else: return(1+sum(x,y-1)); x=10 y=20 print("Sum of two numbers are: ",sum(x,y))

16th Aug 2022, 7:00 PM
Sojib Mia
Sojib Mia - avatar
5 Answers
+ 4
What is it supposed to do? If you want to just add 2 numbers what are you trying to achieve with the recursion?
16th Aug 2022, 7:05 PM
Lisa
Lisa - avatar
0
I went add two number with recursion
16th Aug 2022, 7:14 PM
Sojib Mia
Sojib Mia - avatar
0
Did you run the code? What problem do you get?
16th Aug 2022, 7:18 PM
Lisa
Lisa - avatar
0
it's run properly
16th Aug 2022, 7:24 PM
Sojib Mia
Sojib Mia - avatar
0
This code recursed Y into series of 1, after finish, just add the series to X.
16th Aug 2022, 8:23 PM
abpatrick catkilltsoi
abpatrick catkilltsoi - avatar