--- title: "Magic Numbers" id: 80675 type: "computer_media" slug: "magic-numbers" url: "http://localhost/computer_media/magic-numbers/" markdown_url: "http://localhost/computer_media/magic-numbers.md" published_at: "2026-11-26T15:24:20+00:00" modified_at: "2026-11-26T15:24:20+00:00" featured_image: url: "http://localhost/wp-content/uploads/2026/11/magic-numbers-1.png" excerpt: "Odd-order magic square builder, on the TS2068." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Dick Wagner" slug: "dick-wagner" taxonomy: "indiv" url: "http://localhost/indiv/dick-wagner/" genre: - name: "Mathematics" slug: "mathematics" taxonomy: "genre" url: "http://localhost/type/mathematics/" media_type: "Program" programmers: - name: "Dick Wagner" slug: "dick-wagner" taxonomy: "indiv" url: "http://localhost/indiv/dick-wagner/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Magic%20Numbers%20%281986%29%28Wagner%2C%20Dick%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Magic Numbers (1986)(Wagner, Dick)(TS2068)(US)(Program)/Magic Numbers (1986)(Wagner, Dick)(TS2068)(US)(Program).tap" mediadate: "1986" images: - url: "http://localhost/wp-content/uploads/2026/11/magic-numbers-1.png" - url: "http://localhost/wp-content/uploads/2026/11/magic-numbers-2.png" - url: "http://localhost/wp-content/uploads/2026/11/magic-numbers-3.png" - url: "http://localhost/wp-content/uploads/2026/11/magic-numbers-4.png" article_media: - id: 45333 title: "Magic Numbers" type: "article" url: "http://localhost/article/magic-numbers/" media_type_tags: "Mathematics" license: false --- # Magic Numbers 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](https://timexsinclair.com/article/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 RUN ```