Magic square algorithm java. For n=3 the algorithm works fine.