Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

magic.constant

Magic constant of a magic square or hypercube


Description

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

Usage

magic.constant(n,d=2,start=1)

Arguments

n

Order of the square or hypercube

d

Dimension of hypercube, defaulting to d=2 (a square)

start

Start value. Common values are 0 and 1

Details

If n is an integer, interpret this as the order of the square or hypercube; return n(start+n^d-1)/2.

If n is a square or hypercube, return the magic constant for a normal array (starting at 1) of the same dimensions as n.

Author(s)

Robin K. S. Hankin

See Also

Examples

magic.constant(4)

magic

Create and Investigate Magic Squares

v1.5-9
GPL-2
Authors
Robin K. S. Hankin
Initial release
2018-09-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.