Create the shortest function to print a magic square of given size.
A magic square is a NxN matrix of distinct numbers and the sum of each row, column and diagonal is equal to a constant.
A magic square of size 4 is:
07 12 01 14
02 13 08 11
16 03 10 05
09 06 15 04
And the constant is 34.
The function should be able to handle inputs up to N = 30 and doesn't need to show leading zeroes.
Using Matlab's magic function or similar built-in function is not allowed.
More useful information: http://mathworld.wolfram.com/MagicSquare.html
::Edit::
The output doesn't need to be pretty printed and may contain [](){}, or List/Array delimiters of your language. Although, it should use one line for each row
E.g.
1, 2,
3, 4,
((9,8),
(6,7))
[10 2]
[3 456]
PS: The corner case, when N = 2 is undefined behavior as there's no magic square of that size.
Also, the function should complete in less than 1 minute to avoid brute force.