Arithmetic Series Quiz

See all articles from SYNC v2 n5

One exercise to sharpen arithmetic skills is to use a series of numbers which require discerning the relationships of the numbers in order to complete the series. The program in Listing 1 will print out an arithmetic series. Your task is to figure out the next two numbers in the series. If you are not successful in two tries, the answer is given.

Line 1 stores the data to construct each series. Memory is saved by using the alphabet for storing two digit numbers in the same way that the hexadecimal system uses A to F for representing 10 to 16 in the decimal system. Data is stored in blocks starting with Z which is used as a flag to tell the computer where each block begins.

Line 30 randomizes which block of data is to be used. The computer then searches for the beginning of the block in line 35. A constant is added to the series to make the program more challenging. The end of each block is flagged by the Z of the next block or by 118 (NEWLINE) which is the end of the REM statement. The series is printed on the screen except for the last two numbers which the player has to figure out.

The program is packed tightly in 1K RAM on the ZX80 and requires over 1K RAM on the ZX81. Memory is saved by using keyboard commands in lines 170, 600, and 610. In this way the program provides the maximum variety of series in the small memory.

To exit the program, key in a unused variable letter when asked for a number, or key in a character when “N/L FOR NEW SERIES” is printed.

Enter the program in Listing 1. If you have the 4K ROM make the changes in Listing 2 as you enter the program. Hit RUN and ENTER, and stretch your arithmetic perceptions.

Listing 1. Arithmetic Series Quiz Program (8K ROM).

   1 REM Z019238457Z607162534Z04
815926AZ3074B8FCJZ405366798Z0341
56278Z420642664Z02B35B68BZ042646
6A8Z0257ACFHKZ1L3N5P7R9ZA9865421
0Z0235689BCEZCB9865320Z00244688A
Z051627384Z320542764Z02441355246
6ZAGF8ED5CB1A9
14 DIM V(12)
15 DIM G(2)
20 LET R=INT (RND*100)+1
22 LET K=0
25 LET L=0
30 LET M=16513+INT (RND*197)+1
35 IF PEEK M=63 THEN GOTO 50
40 LET M=M-1
45 GOTO 35
50 LET M=M+1
55 IF PEEK M=63 OR PEEK M=118
THEN GOTO 95
70 LET L=L+1
75 LET V(L)=PEEK M-28+R
80 GOTO 50
95 GOSUB 500
110 PRINT
115 GOSUB 600
120 IF G(1)=V(L-1) AND G(2)=V(L
) THEN GOTO 150
125 GOSUB 500
130 PRINT "? ";G(1);",";G(2)
132 PRINT
133 PRINT TAB 8;"NO"
134 IF K=1 THEN PRINT V(L-1);",
";V(L)
135 IF K=1 THEN GOTO 170
136 LET K=1
140 GOSUB 600
145 GOTO 120
150 GOSUB 500
155 PRINT G(1);",";G(2)
160 PRINT
165 PRINT TAB 8;"YES"
170 PRINT "N/L FOR NEW SERIES"
175 INPUT A$
180 IF A$="" THEN GOTO 20
185 STOP
500 CLS
505 FOR I=1 TO L-2
510 PRINT V(I);",";
515 NEXT I
520 RETURN
600 PRINT " INPUT ";L-1;"TH NU
MBER"
605 INPUT G(1)
610 PRINT " INPUT ";L;"TH NUMBE
R"
615 INPUT G(2)
620 RETURN

Listing 2. Changes for 4K ROM.

  20 LET R=RND(100)
30 LET M=16426+RND(197)
35 IF PEEK(M)=63 THEN GOTO 50
55 IF PEEK(M)=63 OR PEEK(M)=11
8 THEN GOTO 95
75 LET V(L)=PEEK(M)-28+R
133 PRINT ,"NO"
165 PRINT ,"YES"

[Figure: Screen displays: “40,40,42,44,44,46,48, / INPUT 8TH NUMBER / INPUT 9TH NUMBER” and “40,40,42,44,44,46,48,? 50,52 / NO / INPUT 8TH NUMBER”]

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.