UP | HOME
../../ 2015-06-15

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.

  1. An n x n magic square that contains the integers from 1 to n2 is called a normal magic square.
  2. Construct a program that takes n as an argument and generates a normal magic square of n x n.
  3. Is this possible to do for all n > 0? What does it take to prove or disprove this?
  4. 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!]
  5. How can you be sure that it works (or not) for all odd n?
  6. 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.

Copyright © 2015 • www.wright.edu/~pmateti • 2015-06-15