How to sum with previous values multiplied on %?

48 Views Asked by At

I have starting value $X$. I need sum $X$ with $X\cdot Y$ from previous result $Z$ times. So it will require :

$ X + [X + XY] + [X + (X + XY)Y] + [X + (X + (X + XY)Y)Y] + \dots - Z $

iterations.

How do you find formula?

I would start with:

$$ ... = X + X[1 + Y] + X[1 + (1 + Y)Y] + ... = X(1 + [1 + Y] + [1 + Y + Y^2] + ...) = X(Z + (Z - 1)Y + (Z - 2)Y^2 + ... + Y^(Z - 1)) = ?$$

2

There are 2 best solutions below

0
On BEST ANSWER

Take this sum $$ s = 1 + (1 + a) + (1 + a + a^2) + \ldots (1+a+ \ldots + a^{n-1}) \\ = \frac{1-a}{1-a}+\frac{1-a^2}{1-a} + \frac{1-a^3}{1-a}+ \ldots + \frac{1-a^n}{1-a} \\ = \frac{n - a\frac{1-a^n}{1-a}}{1-a} = \frac{n}{1-a}-a\frac{1-a^n}{(1-a)^2} $$

4
On

I think what you are looking for is: $X ( \sum_{k=0}^{z} ( \sum_{j=0}^{k} Y^k ))$

When $z=0$, you get $X (1)$

When $z=1$, you get $ X (1 + (1+Y))$.

When $z=2$, you get $ X (1 + (1+Y) + (1+Y+Y^2))$.

It seems to be what you expected.