Ethiopian multiplication: Difference between revisions

Content added Content deleted
Line 1,224: Line 1,224:


=={{header|Locomotive Basic}}==
=={{header|Locomotive Basic}}==

{{incorrect|Locomotive Basic|Task asks for three functions to be defined and used in the solution.}}
<lang locobasic>10 x=17:y=34:tot=0
<lang locobasic>10 DEF FNiseven(a)=(a+1) MOD 2
20 DEF FNhalf(a)=INT(a/2)
20 WHILE x>=1
30 DEF FNdouble(a)=2*a
30 PRINT x,
40 x=17:y=34:tot=0
40 IF x MOD 2 THEN tot=tot+y:PRINT y ELSE PRINT
50 WHILE x>=1
50 x=INT(x/2):y=2*y
60 WEND
60 PRINT x,
70 IF FNiseven(x)=0 THEN tot=tot+y:PRINT y ELSE PRINT
70 PRINT "=", tot</lang>
80 x=FNhalf(x):y=FNdouble(y)
90 WEND
100 PRINT "=", tot</lang>


Output:
Output: