+ 1

Guys..How recursion is actually working? I'm so confused 😕

Def tri_recursion (x): if x>0: result= x + tri_recursion (x-1) print ( result) else : return = 0 return result tri_recursion (8)

21st Mar 2020, 5:18 AM
SelvaKumar
3 Answers
+ 2
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2465/?ref=app Read this,this article is very helpful for me try this
21st Mar 2020, 5:25 AM
Muhammad Bilal
Muhammad Bilal - avatar
+ 6
tri_recursion(8) will be treated like thi:- result= 8 + tri_recursion(7) = 8+7+tri_recursion(6) =8+7+6+tri_recursion(5) =8+7+6+5+tri_recursion(4) . . . . =8+7+6+5+4+3+2+1+tri_recursion(0) =8+7+6+5+4+3+2+1+0 as tri_resursion(0) is 0 So the final value of result is 28
21st Mar 2020, 5:28 AM
Arsenic
Arsenic - avatar
+ 2
21st Mar 2020, 11:10 AM
Burey
Burey - avatar