powered by
Returns a regular pandiagonal magic square of order \(6m\pm 1\) using a method developed by Hudson.
hudson(n = NULL, a = NULL, b = NULL)
Order of the square, \(n=6m\pm 1\). If NULL, use the length of a
NULL
a
The first line of Hudson's \(A\) matrix. If NULL, use Hudson's value of c(n-1,0:(n-2))
c(n-1,0:(n-2))
The first line of Hudson's \(B\) matrix. If NULL, use Hudson's value of c(2:(n-1),n,1). Using default values for a and b gives an associative square
c(2:(n-1),n,1)
b
Robin K. S. Hankin
Returns one member of a set of regular magic squares of order \(n=6m\pm 1\). The set is of size \((n!)^2\).
Note that n is not checked for being in the form \(6n\pm 1\). If it is not the correct form, the square is magic but not necessarily normal.
n
C. B. Hudson, On pandiagonal squares of order 6t +/- 1, Mathematics Magazine, March 1972, pp94-96
recurse
hudson(n=11) magicplot(hudson(n=11)) is.associative(hudson(n=13)) hudson(a=(2*1:13)%%13 , b=(8*1:13)%%13) all(replicate(10,is.magic(hudson(a=sample(13),b=sample(13)))))
Run the code above in your browser using DataLab