+ 1

explain this code.

def tri_recursion(k): if(k > 0): result = k + tri_recursion(k - 1) print(result) else: result = 0 return result print("\n\nRecursion Example Results") tri_recursion(6)

17th Jul 2021, 12:05 PM
Harsh Kumar
Harsh Kumar - avatar
4 Respuestas
0
Given a value k, if k is greater than 0 print k + the result of tri_recursion(k -1). Let k = 3 K > 0 Result = 3 + 5 (k-1 -> 2 + k -> 5) Result = 8
17th Jul 2021, 12:24 PM
George Ryan
George Ryan - avatar
0
5???
17th Jul 2021, 12:43 PM
Harsh Kumar
Harsh Kumar - avatar
0
I can't understand
17th Jul 2021, 12:43 PM
Harsh Kumar
Harsh Kumar - avatar
0
Can u explain briefly please
17th Jul 2021, 12:47 PM
Harsh Kumar
Harsh Kumar - avatar