Numbers

Date: 198x
Type: Program
Platform(s): TS 2068

Generates a 4×4 magic square based on user input.

Appears on

Library tape of the Indiana Sinclair Timex User’s Group.

Gallery

Numbers

Source Code

    5 REM "NUMBER"
   10 PRINT "THINK OF A NUMBER."
   20 INPUT A
   25 PRINT "    YOU SELECTED  ";A;"."
   30 IF A<15 THEN PRINT "YOUR NUMBER WILL BE USED BUT IT IS TO SMALL."
   35 IF A<31 AND A>14 THEN PRINT "WE WILL ACCEPT YOUR NUMBER BUT WOULD PREFER A LARGER NUMBER."
   40 IF A>30 AND A<55 THEN PRINT "THAT IS A REASONABLE NUMBER."
   45 IF A>54 AND A<100 THEN PRINT "WE WILL ACCEPT YOUR NUMBER BUT WOULD PREFER A SMALLER NUMBER."
   50 IF A>99 THEN PRINT "YOUR NUMBER IS TOO LARGE BUT IT WILL BE USED ."
   55 LET B=INT ((A-30)/4)
   60 PRINT AT 5,8;B+8,AT 5,12;B+5, AT 5,16;B+2
   62 IF A=31 THEN PRINT AT 5,20;16,AT 7,12;15,AT 9,8;14,AT 11,16;13
   63 IF A=32 THEN PRINT 11,16;14,AT 9,8;15,AT 5,20;17,AT 7,12;16
   65 IF (A-30)/4=B+.25 THEN PRINT AT 5,20;B+16,AT 7,12;B+15,AT 9,8;B+14,AT 11,16;B+13
   70 PRINT AT 7,8;B+3,AT   7,16;B+9,AT  7,20;B+4 
   75 IF (A-30)/4=B+.5 THEN PRINT AT 5,20;B+17,AT 7,12;B+16,AT 9,8;B+15,AT 11,16;B+14
   80 PRINT AT 9,12;B,AT 9,16;B+7,AT 9,20;B+10
   85 IF (A-30)/4=B+.75 THEN PRINT AT 5,20;B+18,AT 7,12;B+17,AT 9,8;B+16,AT 11,16;B+15
   90 PRINT AT 11,8;B+6,AT 11,12;B+11,AT 11,20;B+1
   95 IF (A-30)/4=B THEN PRINT AT 5,20;B+15,AT 7,12;B+14,AT 9,8;B+13,AT 11,16;B+12
  100 PRINT 
  105 PRINT 
  110 PRINT "THIS IS A 4 BY 4 MAGIC SQUARE"
  115 PRINT "FOR ";A;". THE SUM  OF HORIZONTAL"
  120 PRINT "LINES OR VERTICAL COLUMNS WILL"
  125 PRINT "BE YOUR CHOSEN NUMBER OF ";A;"."
  130 PRINT "ALSO TRY THE DIAGONALS AND"
  135 PRINT "CORNERS."

People

No people associated with this content.

Scroll to Top