Is it possible to have an $n \times n$ magic square with a another magic square of $\frac n 4 \times \frac n 4$ magic square inside it? If so provide an example, if not prove if impossible.


  1. $n$ cannot be 4


  1. A magic square is an $n \times n$ grid filled with numbers 1, ..., $n \times n$ (this goes for the inside square too)
  • 1
    $\begingroup$ I'm assuming $n$ cannot be $4$? (Otherwise, this would be very easy ;) ) $\endgroup$ – Doorknob Dec 16 '14 at 23:45
  • $\begingroup$ @Doorknob Oh yeah, forgot to add that in lol! $\endgroup$ – warspyking Dec 17 '14 at 0:01

It's possible for any $n$ divisible by 4, other than $n=8$.

First, find a magic square of size $n/4$. (This is impossible when $n=8$.) Call it $\mathcal{M}$. Now consider the following 4 by 4 magic square $\mathcal{S}$, using the numbers 0 through 15:

$\left( \begin{array}{ccc} 8 & 5 & 2 & 15 \\ 3 & 14 & 9 & 4 \\ 13 & 0 & 7 & 10 \\ 6 & 11 & 12 & 1 \end{array} \right)$

For each number $k$ in this square, replace it by a copy of $\mathcal{M}$ with every number increased by $kn^2/16$. One can easily check that the resulting square must be magic, because both of the starting squares are.

If you've heard of a tensor product or Kronecker product, then this should feel like the product of two magic squares.

|improve this answer|||||
  • $\begingroup$ Normally a magic square is filled with 1, ..., n (so if a magic square is inside it, it would contain 1, ..., n/4) $\endgroup$ – warspyking Dec 17 '14 at 0:36
  • $\begingroup$ If $\mathcal{M}$ contains the numbers 1 through $n^2/16$, then the procedure in this answer should produce a new square containing the numbers 1 through $n^2$. Unless I screwed up. $\endgroup$ – Lopsy Dec 17 '14 at 0:39
  • $\begingroup$ Could you fix this then? Also look at the clarification I added in the question. $\endgroup$ – warspyking Dec 17 '14 at 0:42
  • $\begingroup$ How do you fill an n by n magic square with the numbers 1 through n? Do you use each number n times? I've never seen a magic square where you're allowed to repeat numbers. $\endgroup$ – Lopsy Dec 17 '14 at 1:06
  • 1
    $\begingroup$ I'll suggest several improvements: 1) you might want to replace "tensor product" with "Kronecker product" since a tensor product is more general, 2) your example $\mathcal{M}$ should have all elements incremented by 1 to meet the spec, 3) for the programmers in the crowd, the MATLAB code snippet big_M = kron( M - 1, ones( n/4, n/4 )*n ) + kron( ones( n/4, n/4 ), S ), where $\mathsf{M} = \mathcal{M}$ and $\mathsf{S} = \mathcal{S}$, might help to clarify the concept. +1 for your answer, though. $\endgroup$ – COTO Dec 17 '14 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.