I have done some recursive problem like Fibonacci and factorial. I am trying to understand the following code which I created to understand recursive more. When I do debug them, I get lost. I need little explanation. If some can put some effort, I will be grateful
Here is my understanding:
#1 (arr, 0, 3)
#2 (arr, 1, 3)
#3 (arr, 2, 3)
#4 (arr, 3, 3):
test = 1 and #4 erased
#3 will call the method again and create stack #4 (arr, 3, 3) in the for loop. which will make test = 2 . #4 erased and # will increase test = 3
#2 will call the method again and create stack #4 (arr, 2, 3) and #5 (arr, 3,3) in the for loop. #5 makes test = 3 and # 4 make test = 4. Stack #3,4 erased. #2 makes test = 5
#1 will increase test = 7
This understanding can be wrong. I am looking for some help please