Skip to content

Instantly share code, notes, and snippets.

Avatar

Phillip Berndt phillipberndt

View GitHub Profile
View magic.jl
function magic!(M::Array{Int}, n::Int)
# Fast magic square generation
#
#
if n % 2 == 1
# Odd-order magic square
# Algorithm: http://en.wikipedia.org/wiki/Magic_square#Method_for_constructing_a_magic_square_of_odd_order
#
ndiv2 = div(n, 2);
for I = 1:n