Consider an $n\times n$ matrix $M\_n$ where the sequence 
$$\{1,2,3,\dots,n^2\} \mod 4=\{1,2,3,0,1,2,3,\dots\}$$ forms a clock-wise spiral, in that given order. For example,
$$M\_4=\begin{bmatrix} 1&2&3&0\\ 0&1&2&1\\ 3&0&3&2 \\ 2&1&0&3 \end{bmatrix} \qquad \text{and} \qquad
M\_5=\begin{bmatrix} 1&2&3&0&1\\ 0&1&2&3&2 \\ 3&0&1&0&3 \\
2&3&2&1&0 \\ 1&0&3&2&1
\end{bmatrix}.$$ 



> 
> **Question.** Is it true that 
>  $$\det(M\_{2n})=3(2n-1)4^{n-1} \qquad \text{and} \qquad
> \det(M\_{2n+1})=-(3n^2-1)4^n\,\,\,?$$
> 
> 
> 


**Added clarification.** To understand the construction of the above matrices, take a look at the matrices [from my other MO question](https://mathoverflow.net/questions/270525/smith-normal-form-for-specialized-matrices). Then, reduce the entries modulo $4$ and follow through by computing the determinants.



Determinants: periodic entries $0,1,2,3$
Yes, it is true. More generally, the entries $1,2,3,0$ can be replaced by arbitrary numbers $a,b,c,d$, in which case the determinant of $M\_n$ can be computed in terms of the four numbers $u = d-b$, $v = a-c$, $U = d+b$ and $V = a+c$ as follows:


* If $n=4k$ for some positive integer $k$, then
$$
\det\left( M\_{n} \right) =\dfrac{1}{4}
v^{n-4}\left( v^{4}-u^{2}v^{2}+\left( U^{2}-V^{2}\right) \left( \left(
2k-1\right) ^{2}v^{2}-\left( 2k\right) ^{2}u^{2}\right) \right) .
$$
* If $n=4k+2$ for some positive integer $k$, then
$$
\det\left( M\_{n} \right) =-\dfrac{1}{4}%
v^{n-4}\left( v^{4}-u^{2}v^{2}+\left( U^{2}-V^{2}\right) \left( \left(
2k+1\right) ^{2}v^{2}-\left( 2k\right) ^{2}u^{2}\right) \right) .
$$
* If $n=4k+1$ for some positive integer $k$, then
$$
\det\left( M\_{n} \right) =\dfrac{1}{2}
u^{n-3}\left( u^{2}\left( v+V\right) -\left( 2k\right) ^{2}v\left(
U^{2}-V^{2}\right) \right) .
$$
* If $n=4k+3$ for some positive integer $k$, then
$$
\det\left( M\_{n} \right) =\dfrac{1}{2}
vu^{n-3}\left( u^{2}+vV-\left( 2k+1\right) ^{2}\left( U^{2}-V^{2}\right)
\right) .
$$


As you can imagine, this is not very fun to prove. I have a writeup ([*The 4-periodic spiral determinant*](http://www.cip.ifi.lmu.de/~grinberg/algebra/spiral4det.pdf)) in which I attempt at making the idea clear without going into all the details; in particular, annoying computations are relegated to [SageMath](https://sagecell.sagemath.org/) and to the reader (and on some occasions to a combination of both). Even at that level of terseness, it is 24 pages long. I would normally hope that something nicer can be found, but with the complexity of the answer I am not too hopeful.


The proof starts out as suggested by @user44191 in one of the comments to the original post; thus the matrix is brought to a form where all entries are zero except for those in northwesternmost $4\times 4$-submatrix and on four sub-antidiagonals (namely, the $1$-st, the $3$-rd, the $5$-th and the $7$-th sub-antidiagonals) below the main antidiagonal. Then, I turn the matrix upside down, so that the sub-antidiagonals become the super-diagonals. I then perform Laplace expansion with respect to the last $4$ rows. All $4 \times 4$-minors from the last $4$ rows can be explicitly computed (only $\dbinom{7}{4}$ of them nonzero, and this can be further reduced by looking at the vanishing of the complementary minors), so it remains to compute the complementary $\left(n-4\right)\times\left(n-4\right)$-minors. For this, [Jacobi's complementary minor theorem](https://mathoverflow.net/questions/87877/jacobis-equality-between-complementary-minors-of-inverse-matrices) turns out to be of use, along with an explicit computation of the inverse of a certain power series.


