magic.constant {magic} | R Documentation |
Returns the magic consant: that is, the common sum for all rows, columns and (broken) diagonals of a magic square
magic.constant(n)
n |
Order of the square |
Returns n(n^2+1)/2. Note that this is correct for
magic squares whose numbers run from 1...n^2. If the
square is numbered 1 ... n^2-1 the correct magic
constant would be n(n^2-1)/2, or
magic.constant(n)-n
.
Robin K. S. Hankin
magic.constant(4)