Magic Squares
A square that is divided into smaller squares, each containing a number, such that the figures in each vertical, horizontal, and diagonal row add up to the same value.
The above def showed up on a web search.
- An n x n magic square that contains the integers from 1 to n2 is called a normal magic square.
- Construct a program that takes n as an argument and generates a normal magic square of n x n.
- Is this possible to do for all n > 0? What does it take to prove or disprove this?
- Here is a solution ./magic.c that works for a few odd numbers n, for sure as verified by examination of the results. [Lost author's name. Sorry!]
- How can you be sure that it works (or not) for all odd n?
- The file ./magic-orig.c was pretty printed into ./magic.c. Compare the two and express your opinions on which one do you prefer to read along with a detailed why.