# Increment a number with a decrementing multiplier N times and have sum total always be equal to X?

(a working semi-related decrement function)

[T]500 = [T]500 * [S]0.156048361
= [N1] (134.8206296 * [M]0.85)
= [N2] (114.5975351 * [M]0.85)
= [N3] (97.40790487 * [M]0.85)
= [N4] (82.79671914 * [M]0.85) = 70.37721127

In this case T = 500 , N = 4, M = 0.85 , S = 0.156048361 = (0.85-1)/0.85^(4+1)-1)

T = Total
N = is how many times you want to decrement.
M = is the multiplier
S = a number you start to decrement = (M-1)/(M^(N+1)-1)

This is possible through the sheer helpfulness of other on stackexchange. I'm an indie game dev. And this is awesome for any kind of numerical progression you want to have a boundary. Such as damage scales, loot scales, expenses etc.

The S calculation assured my results were accurate regardless of how much i fiddled with T, N and M.

## Now the goal is:

Increment a number that gets added X(always the same amount), N times and then multiplied N times(the same N) via linearly decrementing M multiplier and keep the SUM total a specified number. The S calculation for the decrement formula/point provides that kind of preservation of the sum total.

As far as I understand the variable that needs to be calculated for this is the how much the multiplier decrements since i want to be able to adjust the initial value.

This way if i have contraption that produces stuff with a flat value + % of the stuff it has i can tweak the base criteria enough so that it produces half its limit for the third of its time table and have it diminished later.

I can make up the numbers manually and have them add up but I've always wanted a way to do this kind of thing, with actual math.

I assume this looks something like this (you can see i'm not great at it) :

[T]100000 = ( [S]0 + [F]500) * [MS]3 ) = ( [R1]1500 + [F]500 ) * [MS]3 * [MD]?

Where MS*MD = MR

Continue by doing N Times:

(R2 + F) * MR1

(R3 + F) * MR2

Legend:

T = Total
S = Start
F = Flat value to add every time
MS = Starting multiplier
MD = Multiplier decriment
MS * MD = MR

............ Even if you don't calculate it an assessment how doable and/or hard it is - works.

• First off, your second line is tremendously hideous. The equality sign has very low operation priority, understand that $x = 1 + 2$ should be read $x = (1+2)$, not $(x=1)+2$. So for your second line, I read $500 = 70.37721127$. I did not have the courage to read must of the remaining. – Lærne Jul 7 '15 at 15:00
• Your formula for the value $S$ is correct and comes from the formula for the sum of a finite geometric series. One note: in your description of $S$, you have a formula containing a value $C$, which I believe should be $N$. – Tim Thayer Jul 7 '15 at 15:40
• @TimThayer yes messed it up - fixed thx. – helena4 Jul 7 '15 at 15:54
• @helena4 I thought you rushed to write down the computation, not giving much care to how you presented you maths. Now you've split up one equality symbol per line, which is much more readable than putting all those equality symbols on one line while they do not represent equality. The better way would be to index you $T$ variable for each state, then you first line is $T_0 = 500$ followed by $T_1 = T_0 * 0.156048361 = 134.8206296$, $T_2 = T_1 * 0.85 = 114.5975351$... Or you could even write only $500$ on the first line, $500 * 0.156048361 = 134.8206296$ on the second... – Lærne Jul 8 '15 at 7:38