Multiplies two whole numbers the Russian peasant way, using only halving, doubling and addition: while the first number is not zero, add the second number to the product whenever the first is odd, halve the first (dropping the remainder) and double the second. Enter the two numbers and the product is printed.
The listing came from the Seattle T/S User Group newsletter of June 1990, after an article by Dale Fritz; George Chambers entered it as multip.B2. In the printed listing the printer’s font shows <> as ¼½ (line 40) and > as ½ (line 60); the download has <> and >. Line 9000 saves to a Larken disk and is not needed from tape.
Published in Sinc-Link September-October 1990 (Multiplication).
Source Code
5 REM Russian Peasant Multiplication
6 REM
7 REM From the Seattle T/S User Grp June 1990 newsletter
10 INPUT "First number ";x
15 LET product=0
20 INPUT "Second Number ";y
30 IF x=0 THEN PRINT product: STOP
40 IF x/2¼½INT (x/2) THEN LET product=product+y
50 LET x=INT (x/2)
60 IF x½0 THEN LET y=2*y
70 GO TO 30
100 STOP
9000 PRINT USR 100: SAVE "peasan.B1"Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
