Recursively calculate grand total

80 Views Asked by At

Starting January, I have a value of 2.5. Each month I add 2.5. I believe that I = Prt will tell me the final value in December, but I need the running total.

Ex:

---------------------------------------------------------
|       | Jan  | Feb  | Mar  | Apr  | May  | Jun  | ... |
---------------------------------------------------------
| +2.5  | 2.5  | 5    | 7.5  | 10   | 12.5 | 15   | ... | <-- I want a sum of this row
---------------------------------------------------------
| Total | 2.5  | 7.5  | 15   | 25   | 37.5 | 52.5 | ... |
---------------------------------------------------------

The running total of those 6 months is 52.5. Is there a formula to get 52.5?

For reference, I hope to use this in Numbers.app (or Excel) to calculate the price of something that adds 1 unit each month without having to fill out a bunch of cells and getting the sum.

1

There are 1 best solutions below

1
On BEST ANSWER

No need for a recursive approach here, since there's a nifty summation formula that will allow you to calculate each value independently of all the others.

The sum from 1 to n = n(n+1)/2.

Here, n corresponds to the month number. There's also a scalar involved, so you'll have to multiply the above by 2.5.

In particular, for month 6,

  2.5*(i(i+1)/2)
= 2.5*(6(6+1)/2)
= 2.5*(42/2)
= 2.5*21
= 52.5