Meant to write '1 to N^2' in the black stage text Keep in mind no 2x2 magic squares exist (all other N>0 magic squares do exist) Don't hold your breath for large N, this is essentially bogo sort performance but by N^2. The chance of a proper configuration is (# of possible magic squares of size N)/((N^2)!) So this is basically useful up to N = 3, or if you somehow manage to parallelize scratch on a supercomputer.