Nicomacus

See all articles from SYNC v1 n1
Author(s): David Ahl; Laura L. McLaughlin
Publication: SYNC
Pub Details: SYNC v1 n1 (Volume 1, Issue 1)
Date: January/February 1981
Pages: 18
Drawing of a broken classical column
Drawing of a broken classical column

One of the most ancient forms of arithmetical puzzle is sometimes referred to as a “boomerang.” At some time, everyone has been asked to “think of a number,” and, after going through some process of private calculation, to state the result, after which the questioner promptly tells you the number you originally thought of. There are hundreds of varieties of the puzzle.

The oldest recorded example appears to be that given in Arithmetica of Nicomachus, who died about the year 120. He tells you to think of any whole number between 1 and 100 and divide it successively by 3, 5, and 7, teling hin the remainder in each case. On receiving this information, he promptly discloses the number you thought of.

Can you discover a simple method of mentally performing this feat? If not you can see how the ancient mathematician did it by looking at lines 100-120 within the program.

The game was originally programmed by David Ahl and it appeared in his book, Basic Computer Games. This version was translated for the ZX-80 by Laura McLaughlin.

30 PRINT "THINK OF A NUMBER BETWEEN 1 AND 100."
40 PRINT "YOUR NUMBER DIVIDED BY THREE HAS A REMAINDER OF"
45 INPUT A
50 PRINT "YOUR NUMBER DIVIDED BY 5 HAS A REMAINDER OF"
55 INPUT B
60 PRINT "YOUR NUMBER DIVIDED BY 7 HAS A REMAINDER OF"
65 INPUT C
70 PRINT
80 PRINT "LET ME THINK A MOMENT..."
100 LET D=70*A+21*B+15+C
110 IF NOT D>105 THEN GO TO 140
120 LET D=D-105
130 GO TO 110
140 PRINT "YOUR NUMBER WAS ";D;", RIGHT?"
160 INPUT A$
170 IF CODE (A$)=62 THEN GO TO 220
180 IF CODE(A$)=51 THEN GO TO 240
190 PRINT "I DO NOT UNDERSTAND ";A$;". TRY YES OR NO."
200 GO TO 160
220 PRINT "HOW ABOUT THAT."
230 GO TO 250
240 PRINT "I THINK YOUR ARITHMETIC IS IN ERROR."
250 PRINT
260 PRINT "WANT TO TRY ANOTHER?"
270 INPUT A$
280 IF NOT CODE(A$)=62 THEN STOP
290 CLS
300 GO TO 30

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