magic.RdCreate a magic square.
magic(n)A magic square is a square matrix where all row and column sums and also the diagonal sums all have the same value.
This value or the characteristic sum for a magic square of order \(n\) is \(sum(1:n^2)/n\).
Returns an n-by-n matrix constructed from
the integers 1 through N^2 with equal row and column sums.
A magic square, scaled by its magic sum, is doubly stochastic.
magic(3)
#> [,1] [,2] [,3]
#> [1,] 8 1 6
#> [2,] 3 5 7
#> [3,] 4 9 2