I have problem with creating a upper triangular matrix (in order to calculate the determinant) of the following matrix:
$$\begin{pmatrix} 1& 2& 3& ...& n-2 &n-1 &1 \\ 1& 2& 3& ...& n-2& 1&n \\ 1& 2& 3& ...& 1&n-1 &n \\ .& .& .& .& .& .& \\ .& .& .& .& .& .& \\ 1& 2& 1& ...& n-2 &n-1 &n \\ 1& 1& 3& ...& n-2& n-1 &n \\ 1& 2& 3& ...& n-2& n-1 &n \end{pmatrix}$$
One of my attempts included subtracting the first row from the others which got me to this point:
$$\begin{pmatrix} 1& 2& 3& ...& n-2 &n-1 &1 \\ 0& 0& 0& ...& 0& 2-n&n-1 \\ 0& 0& 0& ...& 3-n&0 &n-1 \\ .& .& .& .& .& .& \\ .& .& .& .& .& .& \\ 0& 0& -2& ...& 0 &0 &n-1 \\ 0& -1& 0& ...& 0&0 &n-1 \\ 0& 0& 0& ...& 0&0 &n-1 \end{pmatrix}$$
Any ideas on how to move on from here ?
In a first step, let us switch to the matrix with columns' order completely reversed :
$$M_n=\begin{pmatrix} \color{red}{1}& (n-1)& (n-2)& ...& 3 &2 &1 \\ n& \color{red}{1}& (n-2) & ... &3& 2& 1 \\ n& (n-1)& \color{red}{1}& ...& 3&2 &1 \\ .& .& .& .& .& .& \\ .& .& .& .& .& .& \\ n& (n-1)& (n-2)& ...& \color{red}{1} &2 &1 \\ n& (n-1)& (n-2)& ...& 3& \color{red}{1} &1 \\ n& (n-1)& (n-2)& ...& 3& 2 &\color{red}{1} \end{pmatrix}$$
in this way the disrupting $\color{red}{"1"}$ entries are now situated on the main diagonal.
Remark : Changing the order of the columns of a matrix only changes the sign of its determinant (it is multiplied by the signature of the permutation).
The key fact comes from the following factorization :
$$M_n=P_nQ_n\tag{1}$$
where
$$P_n=\left(\begin{array}{c|cccccc} 1&-(n-1)&&&&&&\\ 1&&-(n-2)&&&&&\\ 1&&&-(n-3)&&&&\\ .& .& .& .& .& .& .&\\ 1&&&&&&&-1\\ \hline 1&&&&&&&\end{array}\right)$$
and
$$Q_n=\left(\begin{array}{cccccc|c} n&(n-1)&&.&3&2&1\\ \hline 1&0&&&&0&0\\ 0&1&&&&0&0\\ &&1&&&&\\ .& .& .& .& .& .& \\ 0&&&&&1&0\end{array}\right)$$
I have generaly replaced $0$ by void places, but in some cases where their presence clarify the situation.
(relationship (1) can be verified by block computations.)
Now, we can conclude because
$$\det(P_n)=(-1)^{(n-1)}.(-1)^{(n-1)} . (n-1)!=(n-1)!$$
(Laplace expansion along the first column) and
$$\det(Q_n)=(-1)^{(n-1)}$$
(expansion along the last column).
Don't forget, in a final step, to take into account the signature of the initial permutation which is rather peculiar (see results in this answer here).
Numerical results :
for $n=1,2,3...$ we get resp. $1,1,−2,−6,24,120,−720,−5040,40320...$
If you want to verify, here is the little Matlab program I have used :