Magic Square Generator

Build a magic square of any size from 3 to 50, where every row, column and main diagonal adds up to the same number. The grid is made with a standard method and updates as you type.

1 Fill in the box

2 Your answer

Your answer shows here as you type.

How to use the Magic Square Generator

  1. Enter the size of the square, from 3 to 50.
  2. Read the grid, which holds each whole number from 1 to the square of the size exactly once.
  3. Check that each row, column and main diagonal adds up to the magic constant shown.

Frequently asked questions

What is a magic square?

A magic square is a square grid of different whole numbers, usually 1 to n squared, where every row, column and both main diagonals add up to the same total.

What is the magic constant?

For an n by n square the magic constant is n(n²+1)/2. For a 3 by 3 square it is 15, for a 4 by 4 square it is 34, and for a 6 by 6 square it is 111.

Does every size have a magic square?

Every size of 3 or more has one. A 2 by 2 square is impossible. The construction differs for odd sizes, sizes divisible by 4, and sizes that are 2 more than a multiple of 4.

Is there only one magic square for each size?

No. Each size has many magic squares, and this tool shows one arrangement produced by a fixed standard method.

Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.