Given a $n\times n$ table is it possible to fill each cell with one of the numbers $1,2,3,\cdots,n$ such that in each column,each row and each diagonal (i.e Denoting $(x,y)$ as number of column and row $(2,1)$ and $(1,2)$ form the first diagonal) every number appears exactly once? For which $n$ can we fill the table?
Context: I've been given this problem on a contest few months ago but just for $n=4,5$ which I solved easily since $n=4$ is impossible and for $n=5$ we have $$$$\begin{array}{|c|c|c|c|c|} \hline 1&2&3&4&5\\ \hline 3&4&5&1&2\\ \hline 5&1&2&3&4\\ \hline 2&3&4&5&1\\ \hline 4&5&1&2&3\\ \hline\end{array}$$$$ But I was interested in a more general statement I think I've also proved that for $n=6$ it's impossible by trying to fill the table manually. My guess is that for even $n$ it's not solvable and for odd $n$ it's solvable but I have no idea how to approach it except to fill it manually.
EDIT: For prime $n$ we can fill each cell $(i,j)$ with $i+2j\pmod{n}$ except when $i+2j\equiv0\pmod{n}$ then we write $n$ instead for example such filling with $n=7$ (the $n=5$ example is the same filling if you look at $(j,i)$ instead of $(i,j)$) $$$$\begin{array}{|c|c|c|c|c|c|c|} \hline 3&5&7&2&4&6&1\\ \hline 4&6&1&3&5&7&2\\ \hline 5&7&2&4&6&1&3\\ \hline 6&1&3&5&7&2&4\\ \hline 7&2&4&6&1&3&5\\\hline 1&3&5&7&2&4&6\\\hline2&4&6&1&3&5&7\\\hline\end{array}$$$$
PROOF OF THE EDIT: For the same row if cells $(i_1,j)$ and $(i_2,j)$ have the same value we have that $$i_1+2j\equiv i_2+2j\pmod{n}$$ implies $i_1\equiv i_2$ which is possible only if $i_1=i_2$. Same logic applies to the column for cells $(i,j_1),(i,j_2)$ we get $$i+2j_1\equiv i+2j_2\pmod{n}$$ when $n$ is prime it implies $j_1=j_2$ if $(i_1,j_1),(i_2,j_2)$ are on a diagonal we have $$|i_1-i_2|=|j_1-j_2|$$ now assuming they have the same value $$i_1+2j_1\equiv i_2+2j_2\pmod{n}$$ then $i_1-i_2\equiv 2(j_2-j_1)\pmod{n}$ which implies $1\equiv \pm 2\pmod{n}$ which is absurd.

Assume that row 1 is 1, 2, 3, etc.
Sizes 1, 2, 3, 4, 6, 8 have no solution. 5, 7, have a unique solution.
This might suggest that there are no solutions for the even cases but there are multiple solutions for the 12 case.
I am running the 9, 10, and 11 cases but, as you may expect, the program gets slower for these larger values. – badjohn Jun 12 '17 at 15:12