Magic Square
Generate, check, print and export normal magic squares of order 3–40.
About this tool
Choose an integer order from 3 to 40 and Generate. A normal magic square uses every integer from 1 to n² exactly once; each row, column and both main diagonals has the same sum M = n(n²+1)/2. Generation checks both uniqueness/range and these sums. Changing the input clears the old result and exports; invalid input is not rounded.
Odd orders use the Siamese method, multiples of four use the complement pattern, and orders 4k+2 use a Strachey four-quadrant construction. These are deterministic examples, not an enumeration of every magic square or random samples. The trivial 1×1 case is outside this tool; order 2 has no normal magic square.
Print produces one A4 page through order 20. Larger squares use four labelled quadrants with the same cell size, keeping the numbers readable; assemble them by their row/column ranges. The print dialog can save as PDF. CSV exports the complete numeric matrix, comma-separated with one row per line and no headers.
Only the input draft stays in memory during page navigation. Reload restores order 5 without calculating. All computation and export happen locally. Reference and 3×3 example: MathWorks magic.