Ethiopian multiplication: Difference between revisions
Ethiopian multiplication un BASIC256 and Yabasic
No edit summary |
(Ethiopian multiplication un BASIC256 and Yabasic) |
||
Line 804:
1 544
= 578
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">outP = 0
x = 17
y = 34
while True
print x + chr(09);
if not (isEven(x)) then
outP += y
print y
else
print
end if
if x < 2 then exit while
x = half(x)
y = doub(y)
end while
print "=" + chr(09); outP
end
function doub (a)
return a * 2
end function
function half (a)
return a \ 2
end function
function isEven (a)
return (a mod 2) - 1
end function</syntaxhighlight>
==={{header|BBC BASIC}}===
Line 1,380 ⟶ 1,412:
= 578
</pre>
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">outP = 0
x = 17
y = 34
do
print x, chr$(09);
if not (isEven(x)) then
outP = outP + y
print y
else
print
fi
if x < 2 break
x = half(x)
y = doub(y)
loop
print "=", chr$(09), outP
end
sub doub (a)
return a * 2
end sub
sub half (a)
return int(a / 2)
end sub
sub isEven (a)
return mod(a, 2) - 1
end sub</syntaxhighlight>
=={{header|Batch File}}==
|