powered by
Returns the magic constant: that is, the common sum for all rows, columns and (broken) diagonals of a magic square or hypercube
magic.constant(n,d=2,start=1)
Order of the square or hypercube
Dimension of hypercube, defaulting to d=2 (a square)
d=2
Start value. Common values are 0 and 1
Robin K. S. Hankin
If n is an integer, interpret this as the order of the square or hypercube; return \(n({\rm start}+n^d-1)/2\).
n
If n is a square or hypercube, return the magic constant for a normal array (starting at 1) of the same dimensions as n.
magic
magic.constant(4)
Run the code above in your browser using DataLab