magic.constant {magic}R Documentation

Magic constant of a magic square

Description

Returns the magic consant: that is, the common sum for all rows, columns and (broken) diagonals of a magic square

Usage

magic.constant(n)

Arguments

n Order of the square

Details

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.

Author(s)

Robin K. S. Hankin

See Also

magic

Examples

magic.constant(4)

[Package Contents]