Magic Square Generator
Generate a magic square (3x3 to 11x11).
Magic constant
65
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
A magic square has every row, column, and diagonal summing to the same value. Odd sizes use Siamese method (Bachet, 1612). Doubly-even sizes (n%4==0) use a marking method. Used in early cryptography, calendars, and as a meditation aid in many cultures.
About
Magic squares have rows, columns, and diagonals all summing to the same value. Odd sizes use the Siamese method. Even sizes use marking patterns. The constant for size n is n(n²+1)/2.
How to use
- Pick a size.
FAQ
Are these all valid magic squares?+
Odd-size and 4×4-multiple sizes generate genuine magic squares. The 6×10×14 sizes use a simpler row-major fill that isn't strictly magic - this is a placeholder for 'singly even' generation, which is more involved.