<s>[INST] Derive $f(i,j) = \frac{(i+j-2) (i+j-1)}{2} + i$ given values table Given
\begin{array}{ll|lllll}
  &        &    &    & j  &    &                      \\ 
  & f(i,j) & 1  & 2  & 3  & 4  & 5                    \\ \hline
  & 1      & 1  & 2  & 4  & 7  & 11                   \\
  & 2      & 3  & 5  & 8  & 12 &                      \\
  i & 3      & 6  & 9  & 13 &    &                      \\
  & 4      & 10 & 14 &    &    & \dots \\
  & 5      & 15 &    &    &    &                     
\end{array}
How to derive the formula $f(i,j) = \frac{(i+j-2) (i+j-1)}{2} + i$ ?
Not sure if there is any trick other than trial and error.
 [/INST] Let's change the coordinates from $(i,j)$ to $(i,u)$, where $u$ is the diagonal number.   
Number of elements in $k$th diagonal is $k$.
That means total number of elements from $1$st to $u$th diagonal is $\sum\limits_{k=1}^{u} k$.
Then $g(i,u) = i+\sum\limits_{k=1}^{u-1}k$ gives the integer value at row $i$, diagonal $u$.
$
\begin{array}{ll|lllll}
  &        &    &    & j  &    &                      \\ 
  & f(i,j) & 1  & 2  & 3  & 4  & 5                    \\ \hline
  & 1      & 1  & 2  & 4  & 7  & 11                   \\
  & 2      & 3  & 5  & 8  & 12 &                      \\
  i & 3      & 6  & 9  & 13 &    &                      \\
  & 4      & 10 & 14 &    &    & \dots \\
  & 5      & 15 &    &    &    &                     
\end{array}
$

Seeing $u=i+j-1$ mustn't be hard. In first quadrant on xy plane, visualize the straight line $x+y=u+1$. On this line, adding up the $x, y$ coordinates of any point gives the constant $u+1$. Flipping the table horizontally makes it easy to see:
$\begin{array}{ll|lllll}
  & 5      & 15 &    &    &    &          \\           
  & 4      & 10 & 14 &    &    & \dots \\
  i & 3      & 6  & 9  & 13 &    &                      \\
  & 2      & 3  & 5  & 8  & 12 &                      \\
  & 1      & 1  & 2  & 4  & 7  & 11                   \\\hline
  & f(i,j) & 1  & 2  & 3  & 4  & 5                    \\ 
  &        &    &    & j  &    &                      \\ 
\end{array}$
</s>