PostNeed help with Recursion Methods

Posts 12 of 2 · Page 1 of 1
Need help with Recursion Methods
Hey! I am working on a school project but I am unable to figure this out. I have tried YouTubeing/Googling tutorials on recurision but a lot of them use the factorial example and that doesnt help me understand how to make this work.

This is the formula I need to use:
FV = P(1+i)n
n= year
i = interest rate
p = inital value

These are 3 inputs
public int PrinAmount;
public decimal interestRate;
public int investPeriod;

This is what the projects PDF says
The future value of the investment will be calculated using a recursive method. The calculated interest will be added to the principal value once every period (year).

My Current Code
Code:
private int RecursiveMethod(int aA)
        {
            /* 
            * FV = P(1+i)n
            * n= year
            * i = interest rate
            * p = inital value
            */
            if (aA==1)
            {
                return 1;
            }
            int testVar = 1 + Convert.ToInt32(interestRate); //Used to trace values passed
            int testVar2 = PrinAmount * testVar; //Used to trace values passed
            return (testVar2 * RecursiveMethod(aA - 1));
            //return PrinAmount*(1+Convert.ToInt32(interestRate))*RecursiveMethod(aA-1) Used Before Added Traces
        }
The return always returns the value 0.

I have no possible idea how to make this work. Its been 3 days since I have started attempting to solve this problem. I will be researching more on this so if I do end up solving the issue I will be sure to explain how I got the recursion method to work.
Might wanna try a for or while loop and do a year++ to increment it every time it does a calculation
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?