(Aug-19-2019, 07:13 AM)everafter Wrote: I thought tri_recursion(6) is the number times it will recuractually that is also true (in this particular case, because you sum every number, i.e. on line 3 you change k by 1 when call tri_recursion(k-1)) - on line 4 you print intermediate results as well as the final one.
if you change your code
def tri_recursion(k): if(k>0): result = k+tri_recursion(k-2) #NOTE THE DIFF HERE print(result) else: result = 0 return result print("\n\nRecursion Example Results") tri_recursion(6)
Output:Recursion Example Results
2
6
12
>>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs