Hello im a student and this is homework so i just need help, thank you. My problem is with this fibonacci sequence, we need to write a recursive function that returns void. I think i pretty much understand recursion. Please help.
I initialized result=1 in the main function. For i, it is the value that the for loop is looping.
DEleted code. Reason, was answer, do not want other students just copying answer.
I'm not sure why this fuction is member of a class, but that's a matter for you.
As for the treatment of result, fib(i - 1) and fib(i - 2) each have their own values right? Now if the functions returned the values, you'd tread those values seperately and add them together.
Now that the values are passed as parameters, they deserve the same treatment. That is, they're seperate values that you add together and place in result. An how do you define seperate values? You define them a seperate local values on the stack.