TITLE: When is a Sudoku like table solvable
QUESTION [10 upvotes]: 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.

REPLY [3 votes]: This is only a partial answer but it is too large to be a comment.  I looked at this problem a long time ago and I wrote a Java program which tried to crack it by brute force and ignorance.  
I only looked at cases in which the first row is the selected symbols in order.  Any other solution is "isomorphic" to one of this form.  
When the size is above 9, I use A, B, C, etc in a hexadecimal style.
For size 1, there is a trivial solution
$$
\begin{array}
{|c|}
\hline
1\\
\hline
\end{array}
$$
for sizes 2, 3, and 4, there is no solution.  
Size 5 has a solution as posted by kingW3 in his original post.  There is a second which is in a sense a reflection.  Each row is offset by 3 to the right which can be viewed as 2 to the left hence the reflection comment.  
Size 6 has no solution.
Size 7 has 4 solutions here is one which is similar to kingW3's solution for size 5.  Each row is offset 2 to the right.  The others are offset by 3, 4, and 5.  
$$
\begin{array}
{|c|c|c|c|c|c|c|}
\hline
1&2&3&4&5&6&7\\
\hline
3&4&5&6&7&1&2\\  
\hline
5&6&7&1&2&3&4\\ 
\hline
7&1&2&3&4&5&6\\
\hline
2&3&4&5&6&1&2\\
\hline
4&5&6&7&1&2&3\\
\hline
6&7&1&2&3&4&5\\
\hline
\end{array}
$$
Note the simple cyclic pattern shared by size 5.  
Size 8 has no solution.  
This hints at a pattern: even unsolvable, odd solvable with a cyclic pattern.  
The pattern does not continue.  At size 9, that cyclic style does not work.  My cracking program just completed for size 9; there is no solution.  
I won't run the cracking program on size 10.  It would probably not finish before I die.  
The cyclic patterns work for size 11.  So, as kingW3 has found, a prime size helps which makes sense once you know.  
However, this does not cover all solutions.  Here is one for size 12.  I have a memory, but no records, of others.  
$$
\begin{array}
{|c|c|c|c|c|c|c|}
\hline
1&2&3&4&5&6&7&8&9&A&B&C\\
\hline
5&6&C&1&B&2&3&A&7&4&8&9\\
\hline
9&A&4&8&6&1&B&5&C&2&7&3\\
\hline
B&7&9&3&A&C&8&1&4&6&5&2\\
\hline
8&C&5&2&7&4&9&6&A&1&3&B\\
\hline
3&B&7&6&C&A&5&4&2&8&9&1\\
\hline
A&4&1&9&8&3&2&B&5&C&6&7\\
\hline
C&8&2&5&1&B&6&9&3&7&A&4\\
\hline
4&1&6&A&3&8&C&7&B&9&2&5\\
\hline
6&3&B&C&9&7&4&2&8&5&1&A\\
\hline
2&9&8&7&4&5&A&3&1&B&C&6\\
\hline
7&5&A&B&2&9&1&C&6&3&4&8\\
\hline
\end{array}
$$
Additional case.
I have a solution for size 25.  It is the cyclic style.  I think that will work if the size is coprime to 2 and 3 but I have not proved that yet.  
The 12 case remains interesting as it is not of the cyclic style.  
Update
On further thought, I now believe for size $n$ and a shift per line of $s$, a cyclic solution exists provided that all of $s - 1$, $s$, and $s + 1$ have order $n$ in $\mathbb{Z}_n$  (as an additive group).  In other words, they are all non-zero and either $1$ or coprime to $n$.  This can be simplified to Jens's rule of odd and not divisible by $3$.
The $12\times12$ example above remains the only exceptional case that we know.