From: "Josep M." Newsgroups: sci.math,rec.puzzles Subject: De la Loubere. WasRe: 5 by 5 magic square solution? Date: Fri, 23 Oct 1998 18:40:06 +0100 herkommer@my-dejanews.com wrote: > > In article <70ktb4$c0q@panix3.panix.com>, > michael@panix.com (Chico Cherry) wrote: > > Hi all, > > > > I'm looking for a solution for a 5 by 5 magic square, using the > > numbers 1 through 25, where the number 1 is placed in the very center > > square. (Please forgive the fact that I'm an idiot and should be able to > > work this out myself). > > The de la Loubre method works fine with a minor modification. Here is a > solution: > > 10 12 19 21 3 > 11 18 25 2 9 > 17 24 1 8 15 > 23 5 7 14 16 > 4 6 13 20 22 > This is NOT a solution in the sense the original poster meant, for the NE-SW diagonal does not add up to 65. Actually, it can be proven that the sent program produces magic squares (rows, colums + main diagonals) if and only if the central value n(n+1)/2 is placed in the center (I mean the program after changing the first position lines). De la Loubere's method is equivalent to the following procedure: let n be odd let i range from 0 to n-1 let j range from 0 to n-1 let rows be numbered from 0 to n-1 let columns too choose A,B,C,D,E,F place i*n+j+1 at row A*i+B*j+C mod n column D*i+E*j+F mod n (in your program B=-1 E=1 A=2 D=-1 C=(n-1)/2=F ) Then: -all positions are filled iff n and A*E-B*D are relative prime -all rows add up to the same iff A p.r. to n and B p.r. to n -all columns ... iff D and E are p.r. to n -if A,B,D,E satisfy all above then ( central value is placed in central position iff the two main diagonals add up to the magic sum ) -ALL diagonals add up to magic sum iff A+D,B+E,A-D,B-E are all prime relative to n From all this -a magic (r+c+d) square can be done by de la Loubere's method with any value placed in central position iff -there exist A,B,D,E such that A*E-B*D,A,B,D,E,A+D,B+E,A-D,B-E are all prime relative to n iff -n and 6 are prime relative or -a magic (r+c+d) square can be done by de la Loubere's method iff -there exist A,B,D,E such that A*E-B*D,A,B,D,E are all prime relative to n iff -n and 2 are prime relative Let, for instance, A=2 B=-1 D=1 E=-2 . This method produces magic squares with chess knight-like "jumps" for any odd n not multiple of 3. These squares have the "all diagonals add up to the magic sum" property. Greetings, Josep M.