What kind of equation am I trying to make? (factoral with addition type of thing)

56 Views Asked by At

So say I have a y = 12. Then I'd like to compute:

(x*12)+(x*11)+(x*10)+(x*9)+(x*8)+(x*7)+(x*6)+(x*5)+(x*4)+(x*3)+(x*2)+(x*1)

or say I have y = 4. Then I'd like to compute:

(x*4)+(x*3)+(x*2)+(x*1)

I'd like to know if there is a name for this type of equation and if there is a simpler way to write it. The reason I'd like to know is because I'm trying to do this in Excel with a y of 3,652 (and x is a cell reference). I wrote a python script that writes the formula for me but it crashes excel when I try to paste a forumula that long. Instead I'm looking for a cleaner way to do this type of math so I can translate that to Excel.

2

There are 2 best solutions below

0
On BEST ANSWER

If you factor $x$ out of your algorithm, you get

$$x(y+(y-1)+(y-2)... + \ 1)$$

What's in the brackets is an arithmetic series. The sum is given by the formula $$\frac{n(a_1+a_n)}{2}$$

where $n$ is the number of terms, $a_1$ is the first term, and $a_n$ is the $n$th term. If you plug the values of your series into the formula, you get

$$\frac{y(y+1)}{2}$$

Multiplying this by $x$ will give you the algorithm you want:

$$\frac{xy(y+1)}{2}$$

0
On

$(x\cdot y)+...+(x\cdot2)+(x\cdot1)$

can be rewritten as

$x(1 + 2 + ... + y)$ with $y = 4$.

Then $(1 + 2 + ... + y - 1 + y)$ is an arithmetic progression (starting with $1$ with $y$ elements and difference equal to $y$).

To get the sum of this arithmetic progression we can use . $$y \cdot (y + 1) / 2$$

This comes from $n \cdot (a_1 + a_n) / 2$, where $n$ is the count of elements, $a_1$ is the first element, and $a_n$ is the $n$-th element (in our case, $y$)

What you search should be $x \cdot y \cdot (y + 1) / 2$.