1\name{magic} 2\alias{magic} 3\title{Creates magic squares} 4\description{ 5 Creates normal magic squares of any order \eqn{>2}{>2}. Uses 6 the appropriate method depending on n modulo 4. 7} 8\usage{ 9magic(n) 10} 11\arguments{ 12 \item{n}{Order of magic square. If a vector, return a list whose 13 \eqn{i}{i}-th element is a magic square of order \code{n[i]}} 14} 15\details{ 16Calls either \code{magic.2np1()}, \code{magic.4n()}, 17or \code{magic.4np2()} depending on the value of \code{n}. Returns a 18magic square in standard format (compare the \code{magic.2np1()} et seq, 19which return the square as generated by the direct algorithm). 20} 21\references{William H. Benson and Oswald Jacoby. \emph{New recreations with 22 magic squares}. Dover 1976. 23} 24\author{Robin K. S. Hankin} 25\seealso{\code{\link{magic.2np1}}, \code{\link{magic.prime}}, 26 \code{\link{magic.4np2}}, 27\code{\link{magic.4n}},\code{\link{lozenge}}, 28 \code{\link{as.standard}}, \code{\link{force.integer}}} 29\examples{ 30magic(6) 31all(is.magic(magic(3:10))) 32 33## The first eigenvalue of a magic square is equal to the magic constant: 34eigen(magic(10),FALSE,TRUE)$values[1] - magic.constant(10) 35 36## The sum of the eigenvalues of a magic square after the first is zero: 37sum(eigen(magic(10),FALSE,TRUE)$values[2:10]) 38 39 40 41} 42\keyword{array} 43