Explore BrainMass

Magic Matrix

Magic matrix
A N*N matrix is called a magic matrix if it is filled with numbers in {1.. N^2} and sum of the values in all rows, columns are equal.

Supposing an odd N, we are planing to describe how to create such a matrix.
Example of such a matrix is as following:

Solution Preview

Select an arbitary cell in matrix ad start with 1.
| |
| |
| 1 |

cell (i,j)=(3,1) is selected. The next number will be placed in the cell (i-1) and(j-1). If this cell is out of bound, i.e

if i-1 <0 then i=N
if j-1 < 0 ...

Solution Summary

A comprehensive step by step agorithm tries to show how to create a N*N magic matrix for odd values of N.