# Way to calculate cumulative sum of a sequence m times without summing all elements m times.

Suppose we have a sequence 2 1 3 1

Now , I want calculate it's cumulative sum m times and determine the element at position x in the sequence.

Lets's say I want to perform cumulative sum operations 3 times and determine 3rd element after those operations. It would look like this

2 5 11 18

2 7 18 36

2 9 27 63

Now , what I have found out till yet is that the 2nd element of sequence can be found out using the formula of nth element of A.P. where diff = first element of seq. and n = m-1.

I also tried this formula but this isn't working correctly.

(M-1)C0*seq[x]+(m)C1*seq[x-1]+(m+1)C2 and so on till seq[1]

here C is combination .

I also think this has something to do with Catalan's triangle , kind of a vague guess but it's touching some lines there.

If your original sequence is $a,b,c,d,e$, your first sums are $$\begin {array} {c c c c c}a&b&c&d&e\\a& a+b& a+b+c& a+b+c+d& a+b+c+d+e \\a&2a+b&2a+2b+c&2a+2b+2c+d&2a+2b+2c+2d+e \\a&3a+b&4a+3b+c&4a+4b+3c+d&4a+4b+4c+3d+e \\a&4a+b&7a+4b+c&8a+7b+4c+d&8a+8b+7c+4d+e \\a&5a+b&11a+5b+c&15a+11b+5c+d&16a+15b+11c+5d+e \\a&6a+b&17a+6b+c&26a+16b+6c+d&31a+26b+16c+6d+e \end{array}$$
The last coefficient in each column is $1$ in all lines. The next to last is $n$ in row $n$. The one before that is $1+T_{n-1}=1+\frac 12n(n-1)$ where $T_n$ is a triangular number. The next are the cake numbers A000125 $C_n=(n^3+5n+6)/6$, the number of regions you can cut a solid into with $n$ planes. Each successive column will have one higher degree in the polynomial. It looks like the next is A000127 which is the number of regions in 4-space formed by $n$ hyperplanes. It seems that pattern will continue, but I don't know the general formula.
Let $a_n\,(n=0,1,2,3,...)$ be a sequence of numbers. Define its iterated partial sums using the recurrence $$S^{(0)}_n=a_n,\quad S^{(k+1)}_n=\sum_{m=0}^n S^{(k)}_m,\tag1$$ so that we have, for example, $$\small\begin{array} &S^{(0)}_0=\color{green}{a_0}, &S^{(0)}_1=\color{blue}{a_1}, &S^{(0)}_2=\color{maroon}{a_2},&...\\ S^{(1)}_0=\color{green}{a_0}, &S^{(1)}_1=\color{green}{a_0}+\color{blue}{a_1}, &S^{(1)}_2=\color{green}{a_0}+\color{blue}{a_1}+\color{maroon}{a_2},&...\\ S^{(2)}_0=\color{green}{a_0}, &S^{(2)}_1=\color{green}{a_0}+(\color{green}{a_0}+\color{blue}{a_1}), &S^{(2)}_2=\color{green}{a_0}+(\color{green}{a_0}+\color{blue}{a_1})+(\color{green}{a_0}+\color{blue}{a_1}+\color{maroon}{a_2}),&...\\ S^{(3)}_0=\color{green}{a_0}, &S^{(3)}_1=\color{green}{a_0}+(\color{green}{a_0}+(\color{green}{a_0}+\color{blue}{a_1})),&... \end{array}\tag2$$ Now we can prove by induction that the following formula holds: $$S^{(k+1)}_n=\sum_{m=0}^n\binom{m+k}k\,a_{n-m}.\tag3$$