Determinant of a matrix of ones, whose anti diagonal elements are zero I'm trying to prove a formula I have constructed for the determinant of a general $n\times n $ real matrix $A$, given here in the case $n=5$:
$$ A = \begin{bmatrix}
1 & 1 & 1 & 1 & 0 \\
1 & 1 & 1 & 0 & 1 \\
1 & 1 & 0 & 1 & 1 \\
1 & 0 & 1 & 1 & 1 \\
0 & 1 & 1 & 1 & 1
\end{bmatrix}.
$$
That is, the matrix containing all 1's apart from the anti-diagonal which consists of zeros.
Using a simple matlab code I've computed the determinants for the first few values of $n$, and have come to the formula
$$ \det A =
\begin{cases}
-(n-1) \hspace{1em}\mbox{ if }\,\,\, n \equiv -1,0\mod 4, \\
n-1 \hspace{2.2em}\mbox{ otherwise,}
\end{cases}
$$
but I'm unsure where to start to prove this.
 A: Let $J$ be the $n\times n$ matrix of all zeros except ones on the anti-diagonal and $e$ be the vector of all ones. Then
$$
A=-J+ee^T.
$$
Now apply the matrix determinant lemma. Note that $J^{-1}=J$.
A: This is easy to calculate by row reduction:
Add all rows to row 1.
$$\det(A) = \begin{vmatrix}
1 & 1 & ... & 1 & 0 \\
1 & 1 & ... & 0 & 1 \\
... & ... & ... & ... & ... \\
1 & 0 & ... & 1 & 1 \\
0 & 1 & ... & 1 & 1
\end{vmatrix}=\begin{vmatrix}
n-1 & n-1 & ... & n-1 & n-1 \\
1 & 1 & ... & 0 & 1 \\
... & ... & ... & ... & ... \\
1 & 0 & ... & 1 & 1 \\
0 & 1 & ... & 1 & 1
\end{vmatrix}\\=(n-1)\begin{vmatrix}
1 & 1 & ... & 1 & 1 \\
1 & 1 & ... & 0 & 1 \\
... & ... & ... & ... & ... \\
1 & 0 & ... & 1 & 1 \\
0 & 1 & ... & 1 & 1
\end{vmatrix}=(n-1)\begin{vmatrix}
1 & 1 & ... & 1 & 1 \\
0 & 0 & ... & -1 & 0 \\
... & ... & ... & ... & ... \\
0 & -1 & ... & 0 & 0 \\
-1 & 0 & ... & 0 & 0
\end{vmatrix}$$
where in the last row we subtracted row 1 from all rows. Now add again all rows to row 1:
$$\det(A)=(n-1)\begin{vmatrix}
0 & 0 & ... & 0 & 1 \\
0 & 0 & ... & -1 & 0 \\
... & ... & ... & ... & ... \\
0 & -1 & ... & 0 & 0 \\
-1 & 0 & ... & 0 & 0
\end{vmatrix}$$
The last determinant is easy now to calculate.
A: Another way, which also give hints on some properties of the matrix, is as follows.
If $\mathbf U_n$ indicates the $n \times n$ matrix with all ones,
and similarly $\mathbf J_n$ the antidiagonal matrix,
i.e. the Exchange Matrix,
then we can write
$$
{\bf A}_n  = {\bf U}_n  - {\bf J}_n 
$$
Then take the matrix $\mathbf S_n$ which is a Lower Triangular matrix, with all ones
in the main and lower diagonals, and with $0$ in the upper ones.
Its determinant is clearly one, and the inverse is also LT, and is the matrix with $1$ in the upper
diagonal, $-1$ in the first lower, and zero elsewhere.
$$
{\bf S}_n ^{\, - \,1}  = {\bf I}_n  - {\bf E}_n 
$$
which is easy to demonstrate, and where the meaning of ${\bf E}_n $ as Shift Matrix is clear.
Then apply the transformation
$$
{\bf S}_n {\bf A}_n {\bf S}_n ^{\, - \,1}  = {\bf S}_n \left( {{\bf U}_n  - {\bf J}_n } \right){\bf S}_n ^{\, - \,1}
  = {\bf S}_n {\bf U}_n {\bf S}_n ^{\, - \,1}  - {\bf S}_n {\bf J}_n {\bf S}_n ^{\, - \,1} 
$$
which means: sum progressively the rows then subtract the columns.
You get
$$
{\bf S}_n {\bf U}_n {\bf S}_n ^{\, - \,1}  = \left( {\matrix{
   0 & 0 &  \cdots  & 1  \cr 
   0 & 0 &  \cdots  & 2  \cr 
    \vdots  &  \vdots  &  \ddots  &  \vdots   \cr 
   0 & 0 &  \cdots  & n  \cr 
 } } \right)\quad \quad {\bf S}_n {\bf J}_n {\bf S}_n ^{\, - \,1}  = \left( {\matrix{
   0 &  \cdots  & { - 1} & 1  \cr 
    \vdots  &  {\mathinner{\mkern2mu\raise1pt\hbox{.}\mkern2mu
 \raise4pt\hbox{.}\mkern2mu\raise7pt\hbox{.}\mkern1mu}}  &  \vdots  &  \vdots   \cr 
   { - 1} &  \cdots  & 0 & 1  \cr 
   0 &  \cdots  & 0 & 1  \cr 
 } } \right)
$$
subtract and you get a simple matrix.
To calculate the determinant, bring last column to first place (taking note of the sign)
and then left multiply by  ${\bf J}_n $ to put it upside-down.
Since 
$$
\left| {{\bf J}_n } \right| = \left( { - 1} \right)^{\,\left\lfloor {n/2} \right\rfloor } 
$$
you end with
$$
\left| {{\bf A}_n } \right| =  - \left( {n - 1} \right)\left( { - 1} \right)^{\,n + \left\lfloor {n/2} \right\rfloor } 
$$
