Jonathan Crispe

Jonathan Crispe

  • NA
  • 46
  • 48.1k

Multiplication using recursion

Nov 23 2011 9:47 PM
i have this value and know how to calculate it but i don't know how to put in a recursion code.
Any advice pls...Thank you

the amount $10000
the interest rate 10%
the investment period 10 years
the total value would $25, 937.42

main calls Ryear(10) return 23579.47
n = 10 return 23579.47 * 1.1
n = 9 return 21435.89 * 1.1
n = 8 return 19487.17 * 1.1
n = 7 return 17715.61 * 1.1
n = 6 return 16105.1 * 1.1
n = 5 return 14641 * 1.1
n = 4 return 13310 * 1.1
n = 3 return 12100 * 1.1
n = 2 return 11000 * 1.1
n = 1 return 10000 * 1.1
n = 0 Return 10000

this just is the example i got from my class...
static void Main(string[] args)
{
    Console.WriteLine(Ryear(10));
    Console.ReadLine();
}
static private int Ryear(int n)
{
      int amount = 10000;
      int
      if (n < 1)
             return 0;
      else
      return Ryear(n-1)+ n;
}




Answers (9)