Navigation

Operators and Keywords

Function List:

C++ API

: magic (n)

Create an n-by-n magic square.

A magic square is an arrangement of the integers 1:n^2 such that the row sums, column sums, and diagonal sums are all equal to the same value.

Note: n must be a scalar greater than or equal to 3. If you supply n less than 3, magic returns either a nonmagic square, or else the degenerate magic squares 1 and [].

Package: octave