4 × 4 · Magic sum S

A 4×4 magic square with your chosen sum

Choose an integer sum and discover two ways to build a magic square

Read the article and explore the construction →

Choose an integer sum and discover two ways to build a magic square

Why does it work?

The numbers 13, 14, 15 and 16 occupy one special cell in every row, column and diagonal. If D = S − 34 = 4q + r, each line gains 3q + (q+r) = D and therefore sums to S. Euclidean division also works when D is negative.

For S below 34, zero and negative entries may appear; all sixteen entries remain distinct. A birthday gift is only one possible use of this square.

Source of inspiration: Arthur Benjamin and Michael Shermer, Secrets of Mental Math: The Mathemagician’s Guide to Lightning Calculation and Amazing Math Tricks, Magic Squares section, pp. 206–209 in the cited edition. The explanation and code are original.