Magic hypercube

In mathematics, a magic hypercube is the k-dimensional generalization of magic squares and magic cubes, that is, an n × n × n × ... × n array of integers such that the sums of the numbers on each pillar (along any axis) as well as on the main space diagonals are all the same. The common sum is called the magic constant of the hypercube, and is sometimes denoted Mk(n). If a magic hypercube consists of the numbers 1, 2, ..., nk, then it has magic number

.

For k = 4, a magic hypercube may be called a magic tesseract, with sequence of magic numbers given by OEISA021003.

The side-length n of the magic hypercube is called its order. Four-, five-, six-, seven- and eight-dimensional magic hypercubes of order three have been constructed by J. R. Hendricks.

Marian Trenkler proved the following theorem: A p-dimensional magic hypercube of order n exists if and only if p > 1 and n is different from 2 or p = 1. A construction of a magic hypercube follows from the proof.

The R programming language includes a module, library(magic), that will create magic hypercubes of any dimension with n a multiple of 4.