Transform the determinant to upper triangular form I have difficulty transforming this determinant
$$\begin{vmatrix}
x&x & x &\dots & x& x\\
a_1 &x &x &\dots &x& x\\
0& a_2& x&\dots &x& x\\
\vdots& \ddots &\ddots &&\vdots&\vdots\\
 0& 0&  0&\dots & a_{n-1}& x 
\end{vmatrix}$$ 
In a form, which has the zeros in the top and the a in the bottom.
I tried performing the elementary row operations. First I multiplied the first row by 1 and add it to the last row, then I multiplied the last row by (-1) and add it to the first row and I get 0s but I also get $-a_X + X$, which won't produce $a_n$. How to "reverse" the triangle?

Replace the first row $R_1$ by $R_1-R_2$: this becomes $\pmatrix{x-a_1&0&0&\dots &0}$. Now replace $R_2$ by $R_2-R_3$, $R_3$ by $R_3-R_4$ and more generally $R_i$ by $R_{i+1}$, $1\leqslant i\leqslant n-1$ (with $i$ increasing, the order is important). The wanted determinant now reduces to that of a diagonal matrix, which is easy to compute.
