DISCLAIMER: I am still in the process of learning c#. I'm seeking a solution, not criticism. Thanks.

I'm working on creating an Amortization Calculator and I'm getting an error when running the program "Index was outside the bounds of the array"

The code causing the error is the method I'm using to store all of the calculated data into an array so that it can be called on later since I have to export all of it to an Excel Spreadsheet.
Since the size of the array is set to exactly the number of data sets being added to it, (since they're set by the same variable) I have no idea whats going wrong here. Everything is fine upon compilation, but at run time it goes to shit.


Code:

        public static double[,] table = new double[(int) term, 3];   /*term is the number of periods in the payment schedule
                                                                                                which varies based on user input*/

        public static void calculate()
        {
            table[1, 1] = payment;                        
            table[1, 2] = balance*(apr/12);          
            table[1, 3] = table[1,1] - table[1, 2];  
            currentBalance = balance - table[1, 3];

            for (int i = 2; (i = (int) term) != 0; i++)
            {
                table[i, 1] = currentBalance;
                table[i, 2] = currentBalance*(apr/12);
                table[i, 3] = table[i, 1] - table[i, 2];
                currentBalance = currentBalance - table[i - 1, 3];
            }
And before someone asks, the reason the first row of the table is being declared outside of the loop, is because the second row(and each row thereon) relies on information calculated in the previous row.