Jump to content

Ethiopian multiplication: Difference between revisions

Line 1,224:
 
=={{header|Locomotive Basic}}==
 
{{incorrect|Locomotive Basic|Task asks for three functions to be defined and used in the solution.}}
<lang locobasic>10 xDEF FNiseven(a)=17:y=34:tot=0(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
2050 WHILE x>=1
50 x=INT(x/2):y=2*y
60 WENDPRINT x,
4070 IF FNiseven(x MOD 2)=0 THEN tot=tot+y:PRINT y ELSE PRINT
70 PRINT "=", tot</lang>
80 x=FNhalf(x):y=FNdouble(y)
90 WEND
70100 PRINT "=", tot</lang>
 
Output:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.