<s>[INST] Calculating the determinant 
Calculate the following determinant of a matrix of order $n$:
  $$\begin{bmatrix}
1 & 0 & 0 & 0 & \cdots & 0 & 1 \\
1 & a_1 & 0 & 0 & \cdots & 0 & 0 \\
1 & 1 & a_2 & 0 & \cdots & 0 & 0 \\
1 & 0 & 1 & a_3 & \cdots & 0 & 0 \\
\cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\
\cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\
1 & 0 & 0 & 0 & \cdots & 1 & a_{n-1}
\end{bmatrix}$$

What I did was to get rid of the $1$ at the top right corner and then applying transpose, at this point the determinant is in button echelon form so the determinant is the product of the values in the diagonal. 
This is the result I got:
$$\prod^{n-2}_{i=1} a_i\left(a_{n-1}a_{n-2}-1\right)\left(a_{n-1}a_{n-2}\right)$$
Is it correct?
Edit: it's wrong.
Edit2: got a different solution now, although it's strange: $$(\prod^{n-1}_{i=1}a_i)^2(\prod^{n-2}_{i=1}a_i)$$
 [/INST] Hint:  Here's how to relate such a determinant of order $n$ to the analogous determinant of order $n-1$; this is the core of a proof by induction of the formula you're looking for.  I'll illustrate with $n=5$.  (When you generalize, you'll have to be careful with the signs.)
\begin{align*}
\left|\begin{matrix}
1 & 0 & 0 & 0 & 1 \\
1 & a_1 & 0 & 0 & 0 \\
1 & 1 & a_2 & 0 & 0 \\
1 & 0 & 1 & a_3 & 0 \\
1 & 0 & 0 & 1 & a_4
\end{matrix}\right|
&=
\left|\begin{matrix}
a_1 & 0 & 0 & 0 \\
1 & a_2 & 0 & 0 \\
0 & 1 & a_3 & 0 \\
0 & 0 & 1 & a_4
\end{matrix}\right|
+
\left|\begin{matrix}
1 & a_1 & 0 & 0 \\
1 & 1 & a_2 & 0 \\
1 & 0 & 1 & a_3 \\
1 & 0 & 0 & 1
\end{matrix}\right|
&&\text{(expanding in first row)} \\
&= a_1 a_2 a_3 a_4
+
\left|\begin{matrix}
1 & a_1 & 0 & 0 \\
1 & 1 & a_2 & 0 \\
1 & 0 & 1 & a_3 \\
1 & 0 & 0 & 1
\end{matrix}\right|
&&\text{(diagonal matrix)} \\
\\ \\
&= a_1 a_2 a_3 a_4
-
\left|\begin{matrix}
1 & 0 & 0 & 1 \\
1 & a_1 & 0 & 0 \\
1 & 1 & a_2 & 0 \\
1 & 0 & 1 & a_3 \\
\end{matrix}\right|
&&\text{($3$ row swaps)}
\end{align*}
(Expanding in the second row also leads to a nice recurrence.)
</s>