Question:
Suppose there is a matrix N x N. You have to put non-repetitive positive
integers in each square that is a matrix element. For example, rc (i,j)
where i = 1 to N, j = 1 to N, so that the sum of each row, column, and
diagonal is the same. Is there an algorithm to calculate a series of sums?
Is there an algorithm which can tell for a given sum whether a matrix can be
formed and what each element rc(i, j) would be and whether this can be
generalized for any matrix size N x N?

Replies:
The type of matrix you are trying to construct is called a magic square.
Most libraries with a reasonable math collection should have something
available by searching under those key words. With luck you will find
Durer's "Melancholia" engraving of 1514 with spectacular analysis of its
substantial "magic" that goes way beyond the basic requirements. It is
shown below.

NEWTON is an electronic community for Science, Math, and Computer Science K-12 Educators, sponsored and operated by Argonne National Laboratory's Educational Programs, Andrew Skipor, Ph.D., Head of Educational Programs.