**dadudemon**

Use this thread for various math that occurs in a game. Instead of 50 different threads, I figure one thread is better.

Question: in a game where you purchase items and the value of the item increments by a certain value every time you purchase it, what is the explicit formula for determining this?

For example:

Items starts at $10.

You want to buy 10 of them.

It increments by $5 every time you purchase one.

What is the total amount of money that you will need to purchase 10 at once?

$10*5 + ((10 * $5) * 5) + 5 *5 = $325

Is that the right formula?

Let's check:

10+15+20+25+30+35+40+45+50+55 = 325

It might be.

Sum up the formula:

(Iv * t/2) + (t * i) * i) + (t/2 * i) = Fv

Iv = initial value

t = times the item purchased (we wanted 10, in the xample)

i = the amount the item increments with each purchase

Fv = final value after the purchase is complete

I know this is a lot of math but this keeps on bothering me and a recursive formula is far too easy to make but difficult to just randomly employ. I need an explicit one so I don't have to keep track of previous values. I don't think the above is correct.

Replace with other items to test:

Iv = 20

i = 10

t = 15

Fv = (20 * 15/2) + (15 * 10) * 10) + (15/2 * 10)

Fv = 1725

Check:

20 + 35 + 50 + 65 + 80 + 95 + 110 + 125 + 140 + 155 + 170 + 185 + 200 + 215 + 230 = 1875

Nope.

So I screwed up somewhere.

((n(n-1))/2) + Iv calculates the final value of the 10th item (in the first example).

n = number of items

(9*10)/2+10 = 55

We know it will cost $55 for the final item.

So I believe I'm onto something there.

Surely there's a much quicker way to go about calculating this.

Seriously, please help me figure this out as it's frustrating me.

Edit - Gauss did a calculation similar to the thing I'm looking for when he was in elementry school. 100+1, 99+2, etc. 101*50 = 5050 which is all the number 1-100 added up.

Maybe I could approach it from that angle. I'll try it.

Edit 2 - That works but it requires I figure out the final item's purchase value before I can make the calculation using Gauss's method. There's got to be an explicit formula for the whole thing.

Question: in a game where you purchase items and the value of the item increments by a certain value every time you purchase it, what is the explicit formula for determining this?

For example:

Items starts at $10.

You want to buy 10 of them.

It increments by $5 every time you purchase one.

What is the total amount of money that you will need to purchase 10 at once?

$10*5 + ((10 * $5) * 5) + 5 *5 = $325

Is that the right formula?

Let's check:

10+15+20+25+30+35+40+45+50+55 = 325

It might be.

Sum up the formula:

(Iv * t/2) + (t * i) * i) + (t/2 * i) = Fv

Iv = initial value

t = times the item purchased (we wanted 10, in the xample)

i = the amount the item increments with each purchase

Fv = final value after the purchase is complete

I know this is a lot of math but this keeps on bothering me and a recursive formula is far too easy to make but difficult to just randomly employ. I need an explicit one so I don't have to keep track of previous values. I don't think the above is correct.

Replace with other items to test:

Iv = 20

i = 10

t = 15

Fv = (20 * 15/2) + (15 * 10) * 10) + (15/2 * 10)

Fv = 1725

Check:

20 + 35 + 50 + 65 + 80 + 95 + 110 + 125 + 140 + 155 + 170 + 185 + 200 + 215 + 230 = 1875

Nope.

So I screwed up somewhere.

((n(n-1))/2) + Iv calculates the final value of the 10th item (in the first example).

n = number of items

(9*10)/2+10 = 55

We know it will cost $55 for the final item.

So I believe I'm onto something there.

Surely there's a much quicker way to go about calculating this.

Seriously, please help me figure this out as it's frustrating me.

Edit - Gauss did a calculation similar to the thing I'm looking for when he was in elementry school. 100+1, 99+2, etc. 101*50 = 5050 which is all the number 1-100 added up.

Maybe I could approach it from that angle. I'll try it.

Edit 2 - That works but it requires I figure out the final item's purchase value before I can make the calculation using Gauss's method. There's got to be an explicit formula for the whole thing.