In the lowest row the numbers 1 to n are written, then rows above consists of the sums of neighboring elements of the row below it (like in Pascal's triangle) until in the highest row only one number stands. F.e. for $n=7$: $$ \begin{matrix} &&&&&&&256&&&&&&\\ &&&&&&112&&144&&&&&\\ &&&&&48&&64&&80&&&&\\ &&&&20&&28&&36&&44&&&\\ &&&8&&12&&16&&20&&24&&\\ &&3&&5&&7&&9&&11&&13&\\ &1&&2&&3&&4&&5&&6&&7 \end{matrix} $$ the result is 256. Now the questions:
- Is there a way to express this result purely in terms of $n$ without writing out and calculating the whole triangle? (Ideally give an induction proof with it.) Is it connected to the triangle numbers? (I am well aware of their formula.)
- Is there a formula to write down any number in the triangle just by knowing its position (for example indexing the triangle in a zick zack pattern from 1 to $T_n$? F.e. for the triangle from above would be indexed like this: $$ \begin{matrix} &&&&&&&28&&&&&\\ &&&&&&27&&26&&&&&\\ &&&&&23&&24&&25&&&&\\ &&&&22&&21&&20&&19&&&\\ &&&14&&15&&16&&17&&18&&\\ &&13&&12&&11&&10&&9&&8&\\ &1&&2&&3&&4&&5&&6&&7 \end{matrix} $$
I have written the a small Python function to investigate, but I fail to see a pattern (the outputs are all over the place and seem to grow quiet fast):
def f(n:int, w:bool=False)->int:
if n<1: return 0
nums=range(1, n+1)
if w:
print(list(nums))
while len(nums)>1:
nums=[nums[i-1]+nums[i] for i in range(1,len(nums))]
if w:
print(nums)
return nums[0]
Is there a general strategy for problems like this?
A good way to see the top sum is this: it is linear in the bottom row. So if you write the bottom row as
$$\begin{pmatrix}-3&-2&-1&0&1&2&3\end{pmatrix}+4\cdot\begin{pmatrix}1&1&1&1&1&1&1\end{pmatrix}$$
then we only need to find the top sum if the bottom row is $\begin{pmatrix}-3&-2&-1&0&1&2&3\end{pmatrix}$ (which is "obviously" $0$ by symmetry) and when the bottom row is $\begin{pmatrix}1&1&1&1&1&1&1\end{pmatrix}$ (which easily comes out as $2^6$: the $2$nd row is "all twos" the $3$rd row is "all fours" etc.).
In general, for any $n$ you will have the bottom row written as:
$$\begin{pmatrix}-\frac{n-1}{2}&-\frac{n-1}{2}+1&\cdots&0&\cdots&\frac{n-1}{2}-1&\frac{n-1}{2}\end{pmatrix}+\frac{n+1}{2}\cdot\begin{pmatrix}1&1&\cdots&1&1\end{pmatrix}$$
(note the first term may have $-\frac{1}{2}, \frac{1}{2}$ instead of $0$ in the middle) and the top element with bottom row made up of "all ones" is $2^{n-1}$ so the total result is $\frac{n+1}{2}\cdot 2^{n-1}=(n+1)\cdot 2^{n-2}$.
Unfortunately, I don't know much about enumerating the triangle.