Magic Square Generator
Generate an odd-order magic square using the Siamese method, where every row, column and diagonal sums to the same magic constant.
Last reviewed by the Radiatus Cloud team
Generate an odd-order magic square where all lines sum to the same total.
Need this done properly for your business?
Radiatus delivers secure cloud, DevOps & compliance engineering.
Generate a magic square
A magic square is a grid of distinct numbers arranged so that every row, every column and both main diagonals add up to the same total, called the magic constant. This generator builds magic squares of odd order, three by three, five by five and so on, using the elegant Siamese method, which places the numbers one to n squared by moving diagonally up and to the right and dropping down whenever a cell is already filled. The magic constant for an order-n square is n times n squared plus one, all divided by two.
For a three-by-three square using one to nine, the magic constant is fifteen.
The oldest recreational puzzle
Magic squares have fascinated people across many cultures for thousands of years, appearing in ancient Chinese legend, Islamic mathematics and European art. The Siamese method is a surprisingly simple rule that reliably produces a magic square for any odd order, which makes it a satisfying demonstration of how a clear algorithm can generate ordered structure. Even-order magic squares exist too but require different, more complex methods.
Verifying that the rows, columns and diagonals all share the same sum is a pleasing confirmation that the construction works. All generation happens locally in your browser.
Related tools
- Data Collection Analysis — Analyze app description to infer data collection.
- Dark Pattern Detector — Scan UX text for manipulative patterns.
- AI Risk Disclosure — Generate disclosure text for AI features.
- Maturity Radar — Generate a radar chart of security maturity.
Frequently Asked Questions
What is a magic square?
A grid of distinct numbers where every row, column and main diagonal adds up to the same magic constant.
What is the magic constant?
For an order-n square filled with one to n squared, it is n times n squared plus one, divided by two, so fifteen for a three-by-three.
What is the Siamese method?
A rule for odd-order squares that places numbers in sequence by moving diagonally up-right and dropping down when a cell is occupied.
Can it make even-order squares?
This tool uses the Siamese method, which works only for odd orders. Even-order magic squares exist but need different construction methods.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Enter an odd order (3, 5, 7...) to generate a magic square.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.