Department of Energy Argonne National Laboratory Office of Science NEWTON's Homepage NEWTON's Homepage
NEWTON, Ask A Scientist!
NEWTON Home Page NEWTON Teachers Visit Our Archives Ask A Question How To Ask A Question Question of the Week Our Expert Scientists Volunteer at NEWTON! Frequently Asked Questions Referencing NEWTON About NEWTON About Ask A Scientist Education At Argonne Magic square algorithm
Name: ankur srivastava
Status: N/A
Age: N/A
Location: N/A
Country: N/A
Date: Around 1995

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?

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.
   16   3   2  13
    5  10  11   8
    9   6   7  12
    4  15  14   1


Click here to return to the Mathematics Archives

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.

For assistance with NEWTON contact a System Operator (, or at Argonne's Educational Programs

Educational Programs
Building 360
9700 S. Cass Ave.
Argonne, Illinois
60439-4845, USA
Update: June 2012
Weclome To Newton

Argonne National Laboratory