A magic square is a square (n x n) array of integers in which each of the integers 1 to n^{2} appears exactly once, and such that the sum of the integers in each row, each column and each diagonal is the same (the ‘magic number’).

The 3×3 problem was presented to me as a party game. Participants were told that the magic number was 15, and asked to construct the square. My method of solving the problem was by writing out the possible sums without regard to the order of their components (there are only 8) and noting that the central element must appear in 4 sums, and the corner elements in 3. 5 is the only number that appears in four sums, 2, 4, 6 and 8 appear in three, and 1, 3, 7 and 9 in only 2. Thus the only possible solution (together with its variants resulting from the symmetry of the square, which can be produced by rotation, reflection and inversion of the elements) is as below

8 1 6

3 5 7

4 9 2

No magic square exists for n = 2 but squares do exist for all n > 2 and the number of possibilities increase very rapidly with n. It happens, however, that all squares of a given n have the same magic number, given by

M = (n^{2} +1)n/2

Methods for constructing magic squares for any given n > 2, but without demonstration of their validity for all n, are given on page 148 et seq. of *Mathematical Recreations* by Maurice Kraitchik (1942). Kraitchik’s book can be read for free and without breach of copyright online (google the author, title and ‘free ebook’). The purpose of the pdf is to validate the methods Kraitchik describes.