RosettaCodeData/Task/Ethiopian-multiplication/Locomotive-Basic/ethiopian-multiplication.basic
2023-07-01 13:44:08 -04:00

10 lines
235 B
Text

10 DEF FNiseven(a)=(a+1) MOD 2
20 DEF FNhalf(a)=INT(a/2)
30 DEF FNdouble(a)=2*a
40 x=17:y=34:tot=0
50 WHILE x>=1
60 PRINT x,
70 IF FNiseven(x)=0 THEN tot=tot+y:PRINT y ELSE PRINT
80 x=FNhalf(x):y=FNdouble(y)
90 WEND
100 PRINT "=", tot