000a

Microcomputer Mathemagic

by Dr. Michael W. Ecker

WELCOME to Micro-Magic! In this column, during the forthcoming months, I would like to share with you some interesting recreational mathematics and computer applications which have been sadly neglected in our schools. I hope that this column will not only amuse and entertain you. but also stimulate you to think about the whys, hows and even the what-ifs. It is also almost certain to have the bonus effect of improving programming know-how — at least it has for me. I hope to hear directly from readers who have some of their own micro-magic which they might allow me to share, as well as superior programs or any other feedback you wish.

DIGIT PREDICTION:

One of the most popular types of parlor tricks is the “prediction” type. In this amusement, the computer asks you to pick any whole number, which is not revealed or INPUTted. Let’s say you pick 1234. You are next asked to add up the digits to your number. In this case, 1+2+3+4=10. Now subtract this last result from your original number (either mentally, or if you must, on a hand calculator). We now have 1234-10=1224.

This is where the computer “does its stuff”. It now asks you to think of any digit (other than 0) in the last answer (1224 in the above). You then enter the number that is left over after you remove the digit that you’ve picked. If you picked “4”, enter 122 when requested. The computer will tell you the digit you picked (in this case, 4)!

Though the digit prediction program (program number one) was produced on a TRS-80 model 3, it is easily modifiable. Make appropriate modifications for your computer such as the ‘clear screen’ command (CLS for TRS-80, HOME for Apple, etc.). CHR$(23) produces double width letters for the TRS-80.

THE REMARKABLE NUMBER 153

Take any whole number which is a multiple of 3 (3, 6, 9, 12, 15, 18, etc.). Suppose you picked 345. Take the cube of each digit and add the cubes: 3*3*3=27. 4*4*4=64. 5*5*5=125. 27+64+125=216.

Now repeat this with the number 216. You should get 225. Repeating gives 141, then 66; then 432; 99; 1458; 702; then 351 and next 153. Once it hits 153 you will find that you keep getting 153 because 1*1*1 + 5*5*5 + 3*3*3 = 1 + 125 + 27 = 153 again!

The remarkable fact is that no matter what multiple of 3 with which you begin, you must eventually hit the number 153. Program two will take any input and test to verify that you have used a multiple of 3. If so, it will then calculate and display the numbers obtained in this process. Readers who are curious as to what happens if the original whole number is not a multiple of 3 are encouraged to modify the program to skip the initial test. In any case, the program terminates when the next number obtained is the same as the previous one. In the case of starting with a multiple of 3, it turns out that 153 is the only multiple of 3 which is the sum of the cubes of its digits, and so the unmodified program should always terminate with 153.

Readers who wish to correspond are encouraged to write me directly. Useful suggestions will be acknowledged, and very original and especially useful ideas may sometimes result in several months subscription extensions courtesy of our generous editor. My address is:

Dr. Michael W. Ecker
COMPUTER GAMING WORLD
Luzerne 8
Viewmont Village
Scranton, PA 18508

Dr. Michael W. Ecker is Assistant Professor of Mathematics at the Pennsylvania State University’s Worthington Scranton Campus in the Scranton, PA area. He is known for his interest in problem solving and recreational math, as well as his newfound addiction for home computing — especially computer gaming.

							1 CLS
							5 PRINT @323, CHR$(23) "MICRO-MAGIC DIGIT PREDICTION"
							8 FOR Z=1 TO 1200:NEXT: REM TIME STALLER TO ALLOW READING
							9 CLS
							10 PRINT:PRINT "THINK OF ANY WHOLE NUMBER":PRINT
							15 FOR Z=1 TO 1500:NEXT Z
							20 PRINT "ADD UP THE DIGITS OF YOUR NUMBER"
							30 PRINT:FOR Z=1 TO 3000:NEXT
							35 PRINT "NOW SUBTRACT RESULT FROM ORIGINAL NUMBER":PRINT
							40 PRINT "PRESS ANY KEY WHEN YOU ARE READY TO CONTINUE";INPUT X$
							45 CLS
							50 PRINT "THINK OF ANY DIGIT IN THE LAST ANSWER (but not 0)"
							60 FOR Z=1 TO 500:NEXT
							65 PRINT
							70 INPUT "WHAT IS THE NUMBER LEFT IF YOU DELETE THAT DIGIT";N$
							75 S=0
							80 FOR I=1 TO LEN(N$)
							85 S=S+VAL(MID$(N$,i,1))
							90 NEXT I
							100 IF S>=9 THEN S=S-9:GOTO 100
							110 A=9-S
							120 FOR Z=1 TO 700:NEXT
							125 CLS
							130 PRINT "CONCENTRATE NOW ON THE MISSING DIGIT..."
							135 FOR Z=1 TO 1000:NEXT
							140 PRINT:PRINT "AHA!  THE MISSING DIGIT IS";A
							145 PRINT:PRINT:PRINT:PRINT:FOR Z=1 TO 1000:NEXT
							150 END
							
							10 CLS
							20 PRINT CHR$(23)"THE REMARKAMBLE NUMBER 153"
							30 PRINT:PRINT "by Dr. Michael Ecker"
							40 FOR Z=1 TO 12000:NEXT
							50 CLS
							60 INPUT "GIVE ME A WHOLE NUMBER WHICH IS A MULTIPLE OF 3";N
							75 N$=STR$(N)
							77 L=LEN(N$)
							80 IF ABS(N-INT(N))>.01 THEN PRINT "A WHOLE NUMBER PLEASE!":GOTO 60
							90 IF ABS(N/3-INT(N/3))>.01 THEN PRINT "A MULTIPLE OF 3 PLEASE!":GOTO 60
							95 S=0
							100 FOR I=1 TO L
							109 REM LEFT BRACKET OR UP ARROW INDICATES EXPONENTIATION
							110 A(I)=(VAL(MID$(N$,i,1)))[3
							120 S=S+A(I)
							130 NEXT I
							140 PRINT "THE NEXT NUMBER IS";S
							150 IF S=N THEN PRINT:PRINT "PROCESS IS COMPLETE"
							155 IF S=N THEN PRINT "TO START AGAIN, TYPE ANY KEY":INPUT X$:GOTO 50
							160 IF S<>N THEN N=S:S=0:GOTO 75
							200 END
							

Source Pages

Continue Reading