Builds an odd-order magic square on the screen: enter the number of rows/columns (an odd number up to 9; even numbers are refused) and it prints the numbers 1 to N squared one by one in their places, every row, column and diagonal adding up to the same total.
Line 300 was printed as COPY, which left the numbers overwriting one another; it is corrected here so the square comes out right. The total printed at the top left is always 0, because the array it adds up is never filled (as printed).
The article says it runs on the TS1000 too, with ** in place of the up arrow in line 200 (not built). Lines 380-430 (COPY, LLIST, NEW and a disk SAVE /3 for the author’s disk system) are after the STOP and are not used by the program.
Published in The Plotter October 1986 (Magic Numbers).
Source Code
10 REM THERE MUST BE AN ODD NUMBER OF COLUMNS/ROWS
100 DIM M(9,9)
110 PRINT AT 10,0;"NUMBER OF COLUMNS/ROW ?"
115 INPUT N
120 CLS
130 IF N/2=INT (N/2) THEN GO TO 110
140 PRINT AT 0,0;" MAGIC NUMBERS";AT 1,0;" ROWS/COLUMNS."
150 REM
160 LET C1=0
170 LET C=INT (N/2)+1
180 LET R=1
185 LET C1=C1+1
190 PRINT AT R*2+1,C*3;C1
200 IF C1=INT (N^2) THEN GO TO 330
210 IF C1/N<>INT (C1/N) THEN GO TO 240
220 LET R=R+1
230 GO TO 185
240 LET C=C+1
250 IF C<=N THEN GO TO 290
260 LET C=1
270 LET R=R-1
280 GO TO 185
290 LET R=R-1
300 IF R>=1 THEN GO TO 185
310 LET R=N
320 GO TO 185
330 LET T=0
340 FOR I=1 TO N
350 LET T=T+M(I,1)
360 NEXT I
370 PRINT AT 0,0;T
375 STOP
380 COPY
390 PAUSE 250
400 LLIST
410 NEW
415 REM CHANGE LINE 420 FOR YOUR METHOD OF SAVE. THIS IS FOR MY DISK SYSTEM
420 SAVE /3
430 RUNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.



