Just like the title I want to ask about formula for $n \times n$ spiral matrix. In particular, I want to know if there's a formula for a given entry in the matrix, without computing the full matrix.
Here is an example of the kind of matrix I'm talking about: $$\left[\begin{matrix} 1 & 2& 3& 4& 5& 6 \\ 20& 21& 22& 23& 24& 7 \\ 19& 32& 33& 34& 25& 8 \\ 18& 31& 36& 35& 26& 9 \\ 17& 30& 29& 28& 27& 10 \\ 16& 15& 14& 13& 12& 11 \end{matrix}\right]$$